Skip to content
Snippets Groups Projects
Verified Commit a1238c25 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Check if user has required role

parent 72ff2611
No related branches found
No related tags found
1 merge request!24Implement mock Private route basing on user role
Pipeline #11731 passed
......@@ -18,9 +18,8 @@ export const PrivateRoute = ({
path,
requiredRoles,
}: Props): JSX.Element => {
const isAuthed = false;
const isAuthed = true;
const userHasRequiredRole = requiredRoles.includes('admin');
const message = userHasRequiredRole
? 'Please log in to view this page'
: 'Your role is not allowed';
......@@ -29,7 +28,7 @@ export const PrivateRoute = ({
exact={false}
path={path}
render={(props: RouteProps) =>
isAuthed ? (
isAuthed && userHasRequiredRole ? (
<Component {...props} />
) : (
<Redirect
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment