fix: bugs
Some checks failed
Format / formatting (push) Successful in 6s
Build / build (push) Successful in 41s
CI / build (push) Failing after 11s
Format / formatting (pull_request) Successful in 6s

This commit is contained in:
2025-04-29 00:28:56 +02:00
9 changed files with 104 additions and 80 deletions

View File

@ -5,7 +5,6 @@ import { createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
import keycloakService from "./services/keycloak";
import { type AuthStore, useAuthStore } from "@/stores/authStore.ts";
import { jwtDecode } from "jwt-decode";
let store: AuthStore;
@ -29,32 +28,6 @@ keycloakService.CallInit(() => {
}
});
type TokenPayload = {
realm_access?: {
roles?: string[];
};
};
function isAdmin(): boolean {
if (store.authenticated && store.user.token) {
try {
const decoded = jwtDecode<TokenPayload>(store.user.token);
const roles = decoded.realm_access?.roles || [];
if (roles.includes("MyINPulse-admin")) {
return true;
} else {
return false;
}
} catch (err) {
console.error("Failed to decode token", err);
}
}
}
// this shit made by me so i can run the canva vue app
//createApp(App).use(router).mount('#app');
@ -97,4 +70,4 @@ app.use(VueKeyCloak,{
} );
*/
export { store, isAdmin };
export { store };