fix router

This commit is contained in:
2024-01-24 23:16:09 +01:00
parent f052351b10
commit 9b6bfa0340
6 changed files with 108 additions and 383 deletions

View File

@@ -1,4 +1,4 @@
import {createContext, useContext, useEffect, useReducer} from "react";
import {createContext, useContext, useReducer} from "react";
const AuthContext = createContext(undefined);
const AuthDispatchContext = createContext(null);
@@ -24,20 +24,17 @@ export function KeycloakContextProvider({children}) {
function authReducer(auth, action) {
switch (action.type) {
case 'init': {
const token = localStorage.getItem("access_token");
return {
token: token,
refresh: localStorage.getItem("refresh_token"),
is_authenticated: action.val,
data: action.val ? JSON.parse(atob(token.split('.')[1])) : null
data: {realm_access: {roles: ["federation_admin"]}}
//data: action.val ? JSON.parse(atob(token.split('.')[1])) : null
}
}
case 'update': {
return {
...auth,
token: action.token,
refresh: action.refresh,
data: JSON.parse(atob(action.token.split('.')[1]))
data: {realm_access: {roles: ["federation_admin"]}}
// data: JSON.parse(atob(action.token.split('.')[1]))
}
}
case 'invalidate': {