front_foundation #13

Merged
piair merged 188 commits from front_foundation into main 2025-05-14 09:08:33 +02:00
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 };