added a few things back that i had deleted before when fixing 502, mainly looking at login fetch, so far everything works, no 502 and livereload is sorta a thing

This commit is contained in:
Me
2022-11-23 02:53:32 +01:00
parent c35bbcefa6
commit 78687a3daa
3 changed files with 26 additions and 16 deletions

View File

@@ -34,12 +34,12 @@ export class AuthenticationController {
console.log('ON EST DANS REDIRECT AUTH CONTROLLER');
console.log('On redirige');
if (request.user.isEnabledTwoFactorAuth === false)
return response.status(200).redirect('http://transcendance:8080');
return response.status(200).redirect('http://transcendance:8080/#/profile');
return response.status(200).redirect('http://transcendance:8080/#/2fa');
}
/**
* GET /api/v2/auth/logout
* POST /api/v2/auth/logout
* Route pour déconnecter l'utilisateur
*/
@Post('logout')

View File

@@ -1,21 +1,27 @@
<script lang="ts">
import Canvas from "./components/Canvas.svelte";
import { createEventDispatcher } from "svelte";
import { push } from "svelte-spa-router";
// import axios from 'axios';
import { onMount } from 'svelte';
import { loginStatus } from './stores/loginStatusStore.js';
import { onDestroy } from 'svelte';
let dispatch = createEventDispatcher();
// tmp for testing
let aData = {
username: '',
}
onMount(async () => {
// console.log('PROFIL SVELTE');
console.log('SplashPage testing if logged in')
// const {data} = await axios.get('http://transcendance:8080/api/v2/user');
fetch('http://transcendance:8080/api/v2/user')
.then((resp) => resp.json())
.then((res) => {
aData.username = res.username;
})
console.log(aData);
// if (data) {
// $loginStatus = true;
// push('/user');
// //push('/user');
// }
});
@@ -25,13 +31,15 @@
window.location.href = 'http://transcendance:8080/api/v2/auth';
// await fetch ('http://transcendance:8080/api/v2/auth');
console.log('you are now logged in');
push('/profile');
//push('/profile');
// it doesn't wait before changing the page tho which is really annoying... maybe the backend needs to be updated idk
// cuz rn i'm doing it in the front and that doesn't seem great...
}
const logout = async() => {
await fetch('http://transcendance:8080/api/v2/auth/logout',);
await fetch('http://transcendance:8080/api/v2/auth/logout', {
method: 'POST',
});
$loginStatus = false;
};

View File

@@ -9,22 +9,24 @@
import active from 'svelte-spa-router/active'
// or i could leave them all and not display if they're active?
// import { createEventDispatcher } from 'svelte';
// let dispatch = createEventDispatcher();
let handleClickHome = () => {
// dispatch('clickedHome');
// profile?
console.log('clicked home')
push('/profile');
};
let handleClickLogout = () => {
let handleClickLogout = async () => {
// dispatch('clickedLogout');
fetch ('http://transcendance:8080/api/v2/auth/logout');
push('/');
$loginStatus = false;
await fetch('http://transcendance:8080/api/v2/auth/logout', {
method: 'POST',
});
console.log('clicked logout header')
$loginStatus = false;
// push('/');
};
</script>