diff --git a/srcs/requirements/svelte/api_front/src/App.svelte b/srcs/requirements/svelte/api_front/src/App.svelte
index 6a0edc78..c51dba57 100644
--- a/srcs/requirements/svelte/api_front/src/App.svelte
+++ b/srcs/requirements/svelte/api_front/src/App.svelte
@@ -1,14 +1,21 @@
-
+
\ No newline at end of file
diff --git a/srcs/requirements/svelte/api_front/src/routes/primaryRoutes.js b/srcs/requirements/svelte/api_front/src/routes/primaryRoutes.js
index 6a27cd68..cdde6640 100644
--- a/srcs/requirements/svelte/api_front/src/routes/primaryRoutes.js
+++ b/srcs/requirements/svelte/api_front/src/routes/primaryRoutes.js
@@ -1,8 +1,11 @@
import NotFound from "../NotFound.svelte";
import ProfilePage from "../ProfilePage.svelte";
import SplashPage from "../SplashPage.svelte";
-import TmpTest from '../TmpTest.svelte';
import TwoFactorAuthentication from '../TwoFactorAuthentication.svelte';
+import UnauthorizedAccessPage from '../components/UnauthorizedAccessPage.svelte';
+import { loginStatus } from "../stores/loginStatusStore";
+import { wrap } from 'svelte-spa-router/wrap'
+import { get } from 'svelte/store';
// "/article/:title": Article, // this is how you would do parameters!
@@ -10,9 +13,52 @@ import TwoFactorAuthentication from '../TwoFactorAuthentication.svelte';
export const primaryRoutes = {
'/': SplashPage,
- '/2fa': TwoFactorAuthentication,
- '/profile': ProfilePage,
- '/profile/*': ProfilePage,
+ // '/2fa': TwoFactorAuthentication,
+ '/2fa': wrap({
+ component: TwoFactorAuthentication,
+ conditions: [
+ (detail) => {
+ // let loggedIn;
+ // loginStatus.subscribe(value => {
+ // loggedIn = value;
+ // });
+
+ const { fortyTwo, tfa } = get(loginStatus);
+
+ console.log('condition in /2fa');
+ // return (loginStatus.fortyTwo && loginStatus.tfa);
+ // console.log($loginStatus.fortyTwo)
+ console.log(fortyTwo);
+ console.log(tfa);
+ return true;
+ }
+ ]
+ }),
+ '/profile': wrap({
+ component: ProfilePage,
+ conditions: [
+ (detail) => {
+ const { fortyTwo, tfa } = get(loginStatus);
+ // console.log(fortyTwo);
+ // console.log(tfa);
+ // return true;
+ return (fortyTwo && tfa);
+ }
+ ]
+ }),
+ '/profile/*': wrap({
+ component: ProfilePage,
+ conditions: [
+ (detail) => {
+ const { fortyTwo, tfa } = get(loginStatus);
+ // console.log(fortyTwo);
+ // console.log(tfa);
+ // return true;
+ return (fortyTwo && tfa);
+ }
+ ]
+ }),
+ '/unauthorized-access': UnauthorizedAccessPage,
'*': NotFound
};
diff --git a/srcs/requirements/svelte/api_front/src/routes/profileRoutes.js b/srcs/requirements/svelte/api_front/src/routes/profileRoutes.js
index f8dd6673..80027901 100644
--- a/srcs/requirements/svelte/api_front/src/routes/profileRoutes.js
+++ b/srcs/requirements/svelte/api_front/src/routes/profileRoutes.js
@@ -2,6 +2,8 @@
import NotFound from "../NotFound.svelte";
import ProfileDisplay from '../ProfileDisplay.svelte';
import ProfileSettings from '../ProfileSettings.svelte';
+import { loginStatus } from "../stores/loginStatusStore";
+import { wrap } from 'svelte-spa-router/wrap'
// establishing the prefix here very clearly so we can have a coherent repeatable structure
export const prefix = '/profile';
@@ -9,8 +11,38 @@ export const prefix = '/profile';
export const profileRoutes = {
'/': ProfileDisplay,
'/settings': ProfileSettings,
- '/fetch': ProfileDisplay,
'*': NotFound
};
+// I think the conditions of access like are you authenticated work best when they are on the parent routes not the nested routes cuz i don't want my header showing up
+
+// export const profileRoutes = {
+// '/': wrap({
+// component: ProfileDisplay,
+// conditions: [
+// (detail) => {
+// const { fortyTwo, tfa } = get(loginStatus);
+// console.log(fortyTwo);
+// console.log(tfa);
+// console.log('in Profile Display');
+// // return true;
+// return (fortyTwo && tfa);
+// }
+// ]
+// }),
+// '/settings': wrap({
+// component: ProfileSettings,
+// conditions: [
+// (detail) => {
+// const { fortyTwo, tfa } = get(loginStatus);
+// // console.log(fortyTwo);
+// // console.log(tfa);
+// // return true;
+// return (fortyTwo && tfa);
+// }
+// ]
+// }),
+// '*': NotFound
+// };
+
// what if i did /#/profile/:id for like not the user? and then based on that did a fetch?
\ No newline at end of file