Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Protected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Protected component to check if the user is authenticated or not and then render the component
* @author Yousuf Kalim
*/
import React, { useEffect, ReactNode, ReactElement } from 'react';
import React, { ReactElement, ReactNode, useEffect } from 'react';
import { Navigate } from 'react-router-dom';
import { Auth, Config } from '../Store';
import Loader from './Loader';
Expand Down Expand Up @@ -34,7 +34,7 @@ function Protected({
isAuthenticated()
.then((res: any) => {
if (res) {
if (roles?.length && roles.includes(res.role)) {
if (roles?.length && roles.some(item => res.roles.includes(item))) {
// If the user is authenticated then set the auth state to true
return setAuth(true);
} else if (!roles?.length) {
Expand Down