Feat/dimentorin landing page (#49)
* feat(dimentorin): slicing landing page menu mentoring * feat(dimentorin): slicing landing page detail mentor * feat(dimentorin): slicing modal booking mentor * feat(dimentorin): slicing landing - resources page * feat(dimentorin): slicing landing - articles page * feat(dimentorin): slicing landing - detail articles page
This commit is contained in:
@@ -16,7 +16,8 @@ const mappingPublicRoutes = [
|
||||
'/auth/new-password',
|
||||
'/auth/register-mentor',
|
||||
'/auth/register-mentor/pending',
|
||||
'/auth/register-mentor/success'
|
||||
'/auth/register-mentor/success',
|
||||
'/resources',
|
||||
];
|
||||
|
||||
const mappingRoutePermissions = [
|
||||
@@ -74,6 +75,11 @@ const mappingRoutePermissions = [
|
||||
},
|
||||
];
|
||||
|
||||
const mappingPublicPrefixRoutes = [
|
||||
'/mentoring',
|
||||
'/articles',
|
||||
]
|
||||
|
||||
//TODO : Fix this later
|
||||
// const redirectToFirstAccessibleRoute = (userPermissions: string[]) => {
|
||||
// const fallback = mappingRoutePermissions.find((route) =>
|
||||
@@ -90,6 +96,13 @@ export const middleware = async ({ request }: LoaderFunctionArgs) => {
|
||||
const token = session_token?.token?.access_token;
|
||||
const userPermissions =
|
||||
session?.role?.permissions?.map?.((perm) => perm?.name) ?? [];
|
||||
|
||||
// Allow to access the landing page without authentication
|
||||
// So, if the route prefix is in the mappingPublicPrefixRoutes, we return null
|
||||
// to indicate that we don't need to authenticate the user
|
||||
if (mappingPublicPrefixRoutes.some((prefix) => pathname.startsWith(prefix))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mappingPublicRoutes.includes(pathname)) {
|
||||
if (token) return redirect('/dashboard');
|
||||
|
||||
Reference in New Issue
Block a user