Skip to content
Snippets Groups Projects
Commit fbc25adb authored by Björn Modée's avatar Björn Modée
Browse files

Add comments

parent 7459544f
No related branches found
No related tags found
No related merge requests found
Pipeline #46753 passed with warnings
...@@ -27,6 +27,7 @@ const SecureRoute: React.FC<SecureRouteProps> = ({ component: Component, authLev ...@@ -27,6 +27,7 @@ const SecureRoute: React.FC<SecureRouteProps> = ({ component: Component, authLev
} }
}, []) }, [])
// If the user is authenticated and wants to log in, redirect to the correct path
if (initialized) { if (initialized) {
if (authLevel === 'login') if (authLevel === 'login')
return ( return (
...@@ -35,6 +36,7 @@ const SecureRoute: React.FC<SecureRouteProps> = ({ component: Component, authLev ...@@ -35,6 +36,7 @@ const SecureRoute: React.FC<SecureRouteProps> = ({ component: Component, authLev
render={(props) => (userAuthenticated ? <Redirect to="/admin" /> : <Component {...props} />)} render={(props) => (userAuthenticated ? <Redirect to="/admin" /> : <Component {...props} />)}
/> />
) )
// the user does not have access to the admin page
else if (compInitialized && viewType && authLevel !== 'admin') { else if (compInitialized && viewType && authLevel !== 'admin') {
return ( return (
<Route <Route
...@@ -44,7 +46,9 @@ const SecureRoute: React.FC<SecureRouteProps> = ({ component: Component, authLev ...@@ -44,7 +46,9 @@ const SecureRoute: React.FC<SecureRouteProps> = ({ component: Component, authLev
} }
/> />
) )
} else }
// the user does not have access to the admin page
else
return ( return (
<Route {...rest} render={(props) => (userAuthenticated ? <Component {...props} /> : <Redirect to="/" />)} /> <Route {...rest} render={(props) => (userAuthenticated ? <Component {...props} /> : <Redirect to="/" />)} />
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment