Skip to content
Snippets Groups Projects

Fix/authorization

Merged Defendi Alberto requested to merge fix/authorization into dev
1 file
+ 4
2
Compare changes
  • Side-by-side
  • Inline
import { Unauthorized } from 'components/NonAuthUser/Unauthorized/Unauthorized';
import { Unauthorized } from 'components/NonAuthUser/Unauthorized/Unauthorized';
 
import { useAuth } from 'hooks/useAuth';
 
import { useRole } from 'hooks/useRole';
import React, { ComponentType, FC } from 'react';
import React, { ComponentType, FC } from 'react';
interface WithAuthProps {
interface WithAuthProps {
@@ -25,8 +27,8 @@ export const withAuthorization = <T extends WithAuthProps = WithAuthProps>(
@@ -25,8 +27,8 @@ export const withAuthorization = <T extends WithAuthProps = WithAuthProps>(
) => {
) => {
const { allowedRoles } = props as T;
const { allowedRoles } = props as T;
const role = 'admin';
const [role] = useRole();
const isAuth = true;
const [isAuth] = useAuth();
// props comes afterwards so the can override the default ones.
// props comes afterwards so the can override the default ones.
return allowedRoles.includes(role) && isAuth ? (
return allowedRoles.includes(role) && isAuth ? (
Loading