front_foundation #9

Closed
mohamed_maoulainine wants to merge 181 commits from front_foundation into main
Showing only changes of commit b5637e4552 - Show all commits

View File

@ -0,0 +1,24 @@
import { jwtDecode } from "jwt-decode";
import { store } from "@/main";
type TokenPayload = {
realm_access?: {
roles?: string[];
};
};
function isAdmin(): boolean {
if (store.authenticated && store.user.token) {
const decoded = jwtDecode<TokenPayload>(store.user.token);
const roles = decoded.realm_access?.roles || [];
if (roles.includes("MyINPulse-admin")) {
return true;
} else {
return false;
}
} else {
return false;
}
}
export { isAdmin };