fix: bugs fixed, we still have the 404 error
Some checks failed
Format / formatting (push) Successful in 5s
Build / build (push) Successful in 40s
CI / build (push) Failing after 9s
Format / formatting (pull_request) Successful in 6s

This commit is contained in:
ALAMI Adnane 2025-04-29 00:40:30 +02:00
parent 8024b8070b
commit b5637e4552

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 };