From 450f6873a680975f832d7e384b4e0cdc009d9269 Mon Sep 17 00:00:00 2001 From: Me Date: Mon, 5 Dec 2022 03:15:57 +0100 Subject: [PATCH] ok so it still works, the settings work more or less properly, and they look better, tho still kinda shit --- .../api_back/src/users/users.controller.ts | 2 + .../api_front/src/pages/SplashPage.svelte | 54 +---- .../src/pages/profile/ProfileDisplay.svelte | 5 +- .../src/pages/profile/ProfilePage.svelte | 14 +- .../src/pages/profile/ProfileSettings.svelte | 194 +++++++++++------- .../svelte/api_front/src/pieces/Button.svelte | 48 +++++ .../svelte/api_front/src/pieces/Header.svelte | 4 +- .../api_front/src/stores/loginStatusStore.js | 7 - 8 files changed, 196 insertions(+), 132 deletions(-) create mode 100644 srcs/requirements/svelte/api_front/src/pieces/Button.svelte diff --git a/srcs/requirements/nestjs/api_back/src/users/users.controller.ts b/srcs/requirements/nestjs/api_back/src/users/users.controller.ts index 55d9dc61..eaa71624 100644 --- a/srcs/requirements/nestjs/api_back/src/users/users.controller.ts +++ b/srcs/requirements/nestjs/api_back/src/users/users.controller.ts @@ -38,6 +38,8 @@ export class UsersController { @UseGuards(TwoFactorGuard) @Get() findOne(@Req() req) { + console.log("Backend Getting current user"); + // console.log(this.usersService.findOne(req.user.id)); return this.usersService.findOne(req.user.id); } diff --git a/srcs/requirements/svelte/api_front/src/pages/SplashPage.svelte b/srcs/requirements/svelte/api_front/src/pages/SplashPage.svelte index d17c1cc3..d6901b2b 100644 --- a/srcs/requirements/svelte/api_front/src/pages/SplashPage.svelte +++ b/srcs/requirements/svelte/api_front/src/pages/SplashPage.svelte @@ -6,19 +6,7 @@ onMount(async () => { - console.log('SplashPage testing if logged in') - // let user = await fetch('http://transcendance:8080/api/v2/user') - // .then((resp) => resp.json()) - // 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 - // } + // console.log('SplashPage testing if logged in') // hold on, maybe this is all i need? let user = await fetch('http://transcendance:8080/api/v2/user') @@ -39,17 +27,7 @@ // console.log('we have a user'); // } - - // for some reason unlike in ProfileDisplay here the user is never undefined... - // ok i think it's because here i declare the user in the call whereas in ProfileDisplay i declare user before... - // if (user !== undefined) { - // console.log('user not undefined') - // } - // else - // console.log('user undefined') - - // to clean up local storage... as a precaution - // this condition isn't good enough... + // user === undefined doesn't work cuz we declared user in the scope of onMount // if (user === undefined) { if (user && user.statusCode && user.statusCode === 403) { console.log('on mount no user, returned status code 403 so logging out of userStore') @@ -63,24 +41,13 @@ 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') - - // ok giving our new local storage and store combo a go - // what i need is to set the store to the user when this button get's pressed - // since there's no apparent return i guess i'll just fetch the user? await fetch('http://transcendance:8080/api/v2/user') .then((resp) => resp.json()) .then((data) => void userStore.set(data)); - // 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() - - // leave this out for now cuz causing problems + // decide if do this here on in backend // push('/profile'); - // idk why this doesn't work, seems really weird, maybe it's an awit thing? - // Maybe it would be better to do it in the Backend? } // i could prolly put this in it's own compoent, i seem to use it in several places... or maybe just some JS? like no need for html @@ -97,21 +64,8 @@
- - -

Potato Pong

- - - +

Potato Pong