2FA Sign In
+use google authenticator
+ {#await fetchQrCodeImg} +Please Wait...
+ {:then data} + +Unable to get QrCodeImg
+ {/await} +diff --git a/srcs/requirements/nestjs/api_back/src/auth/42/authentication.controller.ts b/srcs/requirements/nestjs/api_back/src/auth/42/authentication.controller.ts index ed719d24..08661276 100644 --- a/srcs/requirements/nestjs/api_back/src/auth/42/authentication.controller.ts +++ b/srcs/requirements/nestjs/api_back/src/auth/42/authentication.controller.ts @@ -34,7 +34,7 @@ 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/#/profile'); + return response.status(200).redirect('http://transcendance:8080/'); return response.status(200).redirect('http://transcendance:8080/#/2fa'); } diff --git a/srcs/requirements/svelte/api_front/src/App.svelte b/srcs/requirements/svelte/api_front/src/App.svelte index b1ef3fe9..6a0edc78 100644 --- a/srcs/requirements/svelte/api_front/src/App.svelte +++ b/srcs/requirements/svelte/api_front/src/App.svelte @@ -5,20 +5,6 @@ import { primaryRoutes } from "./routes/primaryRoutes.js"; - // this page should handle the SPA history management... - - // set to false later for actual security - // let loggedIn = true; - - - - // $: logout = async() => { - // await fetch("http://transcendance:8080/api/v2/auth/logout",{ - // method : 'POST', - // }).then(push('/login')); - // } - - diff --git a/srcs/requirements/svelte/api_front/src/ProfileSettings.svelte b/srcs/requirements/svelte/api_front/src/ProfileSettings.svelte index 369c3702..2ba80293 100644 --- a/srcs/requirements/svelte/api_front/src/ProfileSettings.svelte +++ b/srcs/requirements/svelte/api_front/src/ProfileSettings.svelte @@ -3,6 +3,7 @@ import Card from './shared/Card.svelte'; import {onMount} from 'svelte'; import { push } from 'svelte-spa-router'; + import { loginStatus } from './stores/loginStatusStore' let user; @@ -48,6 +49,8 @@ .then(response => response.json()) .then(result => console.log(result)); + // so now we're saying it's like they logged in with 2fa, so they don't have to go do it now + loginStatus.update( (old) => ({...old, tfa: true}) ); push('/profile'); } diff --git a/srcs/requirements/svelte/api_front/src/SplashPage.svelte b/srcs/requirements/svelte/api_front/src/SplashPage.svelte index 2e64d411..9e3141fe 100644 --- a/srcs/requirements/svelte/api_front/src/SplashPage.svelte +++ b/srcs/requirements/svelte/api_front/src/SplashPage.svelte @@ -4,35 +4,35 @@ import { onMount } from 'svelte'; import { loginStatus } from './stores/loginStatusStore.js'; - // tmp for testing - // this is fucking retarded, pardon my offensive language. - let aData = { - username: '', - } + // if logged in it gets the user from backend + // set loginStats.fortyTwo = true + // + 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') + let user = await fetch('http://transcendance:8080/api/v2/user') .then((resp) => resp.json()) - .then((res) => { - aData.username = res.username; - }) - console.log(aData); - // if (data) { - // $loginStatus.42 = true; - // //push('/user'); - // } + if (user) { + if (!user.isEnabledTwoFactorAuth) { + loginStatus.update( (old) => ({...old, tfa: true}) ); + } + // because the User will only exist if they're logged in to 42? + loginStatus.update( (old) => ({...old, fortyTwo: true}) ); + if (user.isEnabledTwoFactorAuth && $loginStatus.tfa) + push('/profile'); + // They have to click Login if using tfa and tfa no already done + } }); const login = () => { - // document.body.scrollIntoView(); - // push 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'); + loginStatus.allTrue(); + // this is redundant if TFA is on because they would only get back here after going through the TFA which sets it to True + // $loginStatus.tfa = true; // also it doesn't do anything cuz no .update() + 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... } @@ -41,10 +41,14 @@ await fetch('http://transcendance:8080/api/v2/auth/logout', { method: 'POST', }); - // $loginStatus.42 = false; - // you're an idiot, the reason this didn't work is because you didn't use update. duh + loginStatus.allFalse() }; + const toProfile = () => { + push('/profile'); + }; + + @@ -53,72 +57,26 @@
FortyTwo: {$loginStatus.fortyTwo}
-TFA: {$loginStatus.tfa}
-isLogged: {loginStatus.isLogged}
- -use google authenticator
+ {#await fetchQrCodeImg} +Please Wait...
+ {:then data} + +Unable to get QrCodeImg
+ {/await} +