diff --git a/front/app/_orgs/[orgslug]/settings/layout.tsx b/front/app/_orgs/[orgslug]/settings/layout.tsx index 6ea3bb6b..ce669246 100644 --- a/front/app/_orgs/[orgslug]/settings/layout.tsx +++ b/front/app/_orgs/[orgslug]/settings/layout.tsx @@ -3,18 +3,16 @@ import React, { createContext, useState } from 'react' import { styled } from '@stitches/react'; import Link from 'next/link'; import LearnHouseWhiteLogo from '@public/learnhouse_text_white.png'; -import { AuthContext } from '@components/Security/AuthProvider'; +import AuthProvider, { AuthContext } from '@components/Security/AuthProvider'; import Avvvatars from 'avvvatars-react'; import Image from 'next/image'; - - - function SettingsLayout({ children, params }: { children: React.ReactNode, params: any }) { const auth: any = React.useContext(AuthContext); return ( - <> + <> +
diff --git a/front/components/Security/AuthProvider.tsx b/front/components/Security/AuthProvider.tsx index 3fc11e39..81222a66 100644 --- a/front/components/Security/AuthProvider.tsx +++ b/front/components/Security/AuthProvider.tsx @@ -5,7 +5,7 @@ import { useRouter, usePathname } from "next/navigation"; export const AuthContext: any = React.createContext({}); -const PRIVATE_ROUTES = ["/course/*/edit",]; +const PRIVATE_ROUTES = ["/course/*/edit", "/settings*"]; const NON_AUTHENTICATED_ROUTES = ["/login", "/register"]; export interface Auth { @@ -48,7 +48,7 @@ const AuthProvider = ({ children }: any) => { } else { setAuth({ access_token, isAuthenticated: false, userInfo, isLoading }); - + // Redirect to login if user is trying to access a private route if (PRIVATE_ROUTES.some((route) => new RegExp(`^${route.replace("*", ".*")}$`).test(pathname))) { router.push("/login"); @@ -56,7 +56,7 @@ const AuthProvider = ({ children }: any) => { } } catch (error) { - + } }