fix logout bug
@@ -27,7 +27,8 @@ export type State = {
const AUTHORIZED_TOKEN_KEY = "AUTHORIZED_TOKEN_KEY";
-const initialState: State = {
+const getInitialState = () => {
+ return {
authorized: false,
firstLoaded: false,
isLoading: false,
@@ -40,6 +41,10 @@ const initialState: State = {
impersonationType: "",
permissionMethods: emptyPermissionMethods,
};
+};
+
+// prevent LOGOUT reset token bug
+const initialState: State = getInitialState();
const reducer = produce((state: State, action: Actions) => {
switch (action.type) {
@@ -70,7 +75,7 @@ const reducer = produce((state: State, action: Actions) => {
}
case LOGOUT: {
window.localStorage.removeItem(AUTHORIZED_TOKEN_KEY);
- return initialState;
+ return getInitialState();
}
case SET_AUTH_METHODS: {
state.permissionMethods = action.payload;
