Added check permission
This commit is contained in:
parent
e2bba609e6
commit
d4851764fe
|
|
@ -13,6 +13,7 @@ interface AuthContextType {
|
||||||
accessToken?: NonNullable<AuthContextType["accessToken"]>
|
accessToken?: NonNullable<AuthContextType["accessToken"]>
|
||||||
) => void;
|
) => void;
|
||||||
clearAuthData: () => void;
|
clearAuthData: () => void;
|
||||||
|
checkPermission: (permission: string) => boolean;
|
||||||
isAuthenticated: boolean;
|
isAuthenticated: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,6 +50,10 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||||
localStorage.removeItem("accessToken");
|
localStorage.removeItem("accessToken");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkPermission = (permission: string) => {
|
||||||
|
return permissions?.includes(permission) ?? false;
|
||||||
|
};
|
||||||
|
|
||||||
const isAuthenticated = Boolean(accessToken);
|
const isAuthenticated = Boolean(accessToken);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -61,6 +66,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||||
saveAuthData,
|
saveAuthData,
|
||||||
clearAuthData,
|
clearAuthData,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
|
checkPermission,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user