CEC-2977 Filter portal access based on auth provider (#231)
* fix/fleet-vehicles-search * fix/fleet-name-update * Update hasRole logic, create RoleWrap component * Add MAGNA and MAGNAGROUP env vars * Add Permissions Co-authored-by: jwu-fisker <jwu@fiskerinc.com>
This commit is contained in:
@@ -8,7 +8,7 @@ export const TYPES = {
|
||||
PROTECTED: 2,
|
||||
};
|
||||
|
||||
export const AuthRoute = ({ token, type, roles, groups, ...others }) => {
|
||||
export const AuthRoute = ({ token, type, groups, rolesPerGroup, providers, ...others }) => {
|
||||
if (type === TYPES.PROTECTED && !token) {
|
||||
return <Redirect to="/" />;
|
||||
} else if (type === TYPES.GUEST && token) {
|
||||
@@ -16,8 +16,9 @@ export const AuthRoute = ({ token, type, roles, groups, ...others }) => {
|
||||
} else if (
|
||||
type === TYPES.PROTECTED &&
|
||||
token &&
|
||||
roles &&
|
||||
!hasRole(roles, groups)
|
||||
rolesPerGroup &&
|
||||
providers &&
|
||||
!hasRole(groups, rolesPerGroup, providers)
|
||||
) {
|
||||
return <Redirect to="/home" />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user