From e9236cc18f954eb2ec13036214cfa8fd2a2ec816 Mon Sep 17 00:00:00 2001 From: jamesschuler Date: Tue, 30 May 2023 14:12:27 -0700 Subject: [PATCH] home page content; featured toggled login / profile pages; adjusted styles --- api/index.ts | 3 +- frontend/index.html | 2 +- frontend/src/components/Navbar.vue | 24 ++++++++++--- frontend/src/pages/HomePage.vue | 10 ++++-- frontend/src/pages/NotFoundPage.vue | 7 ++++ frontend/src/router.ts | 52 ++++++++++++++++------------- frontend/src/stores/commonStore.ts | 5 +++ 7 files changed, 71 insertions(+), 32 deletions(-) create mode 100644 frontend/src/pages/NotFoundPage.vue diff --git a/api/index.ts b/api/index.ts index 9f2d4e9..69d2fed 100644 --- a/api/index.ts +++ b/api/index.ts @@ -17,8 +17,7 @@ const store = new CookieStore(Deno.env.get("COOKIE_STORE_SECRET")!); app.use(Session.initMiddleware(store, { cookieSetOptions: { httpOnly: true, - sameSite: "none", - secure: true, + sameSite: "lax", }, })); diff --git a/frontend/index.html b/frontend/index.html index 3d1e5fd..0b92315 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -19,7 +19,7 @@ rel="stylesheet" /> - +
diff --git a/frontend/src/router.ts b/frontend/src/router.ts index 918456c..b6a123a 100644 --- a/frontend/src/router.ts +++ b/frontend/src/router.ts @@ -1,13 +1,15 @@ import HomePage from "@/pages/HomePage.vue"; import LoginPage from "@/pages/LoginPage.vue"; +import NotFoundPage from "@/pages/NotFoundPage.vue"; import ProfilePage from "@/pages/ProfilePage.vue"; import SearchTrainersPage from "@/pages/SearchTrainersPage.vue"; import { useAuthStore } from "@/stores/authStore"; import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"; -const routes: Array = [ +let routes: Array = [ { path: "/", + name: "Home", component: HomePage, }, { @@ -16,30 +18,35 @@ const routes: Array = [ component: SearchTrainersPage, }, { - path: "/login", - name: "Login", - component: LoginPage, + path: "/:pathMatch(.*)*", + name: "NotFound", + component: NotFoundPage, }, - { - path: "/profile", - name: "Profile", - component: ProfilePage, - meta: { - requiresAuth: true, - }, - }, - // { - // path: '/error', - // name: 'Error', - // component: Error - // }, - // { - // path: '/:pathMatch(.*)*', - // name: 'NotFound', - // component: NotFound - // }, ]; +if (import.meta.env.VITE_APP_ACCOUNTS_FEATURE_TOGGLE === "true") { + routes = [ + ...routes, + { + path: "/login", + name: "Login", + component: LoginPage, + meta: { + featureToggle: "accounts", + }, + }, + { + path: "/profile", + name: "Profile", + component: ProfilePage, + meta: { + requiresAuth: true, + featureToggle: "accounts", + }, + }, + ]; +} + const router = createRouter({ history: createWebHistory(), routes, @@ -47,7 +54,6 @@ const router = createRouter({ router.beforeEach((to, _from, next) => { const authStore = useAuthStore(); - const requiresAuth = to.matched.some((record) => record.meta.requiresAuth); if (requiresAuth && !authStore.isLoggedIn) { diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index c90550e..be2956b 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -4,7 +4,12 @@ import { ref } from "vue"; export const useCommonStore = defineStore("common", () => { const showOverlay = ref(false); + const featureToggles = ref({ + accounts: import.meta.env.VITE_APP_ACCOUNTS_FEATURE_TOGGLE === "true", + }); + return { + featureToggles, showOverlay, }; });