generated from fahricansecer/boilerplate-fe
Initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Auth Configuration
|
||||
* Controls whether authentication is required for the app
|
||||
*/
|
||||
|
||||
export const authConfig = {
|
||||
// If true, users must login to access the app
|
||||
// If false, app is public with optional login
|
||||
isAuthRequired: process.env.NEXT_PUBLIC_AUTH_REQUIRED === "true",
|
||||
|
||||
// Public routes that don't require authentication (when auth is required)
|
||||
publicRoutes: ["/signin", "/signup", "/forgot-password"],
|
||||
|
||||
// Routes that should always be protected (even when auth is optional)
|
||||
protectedRoutes: ["/admin", "/settings", "/profile"],
|
||||
};
|
||||
|
||||
export const isPublicRoute = (pathname: string): boolean => {
|
||||
return authConfig.publicRoutes.some((route) => pathname.includes(route));
|
||||
};
|
||||
|
||||
export const isProtectedRoute = (pathname: string): boolean => {
|
||||
return authConfig.protectedRoutes.some((route) => pathname.includes(route));
|
||||
};
|
||||
Reference in New Issue
Block a user