fix logout problems

This commit is contained in:
martin-mfg
2026-01-07 12:10:40 +01:00
parent 2ed549da57
commit 905db1d29b
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -2,6 +2,7 @@ import axios from 'axios';
import { HOST } from '../constants';
import { logout } from '../redux/actions/userActions';
import { useDispatch } from 'react-redux';
const authenticate = async (code, privateAccess, userKey) => {
try {
@@ -22,13 +23,14 @@ const authenticate = async (code, privateAccess, userKey) => {
};
const getUserMetadata = async (userKey) => {
const dispatch = useDispatch();
try {
const fullUrl = `https://${HOST}/api/user-access?user_key=${userKey}`;
const result = await axios.get(fullUrl);
return result.data;
} catch (error) {
if (error.response && error.response.status === 404) {
logout(userKey);
dispatch(logout(userKey));
}
console.error(error);
return null;
+1 -1
View File
@@ -21,7 +21,7 @@ export default (state = initialState, action) => {
case types.LOGOUT:
if (
action.payload.userKey !== null &&
action.payload.userKey !== localStorage.getItem('userKey')
action.payload.userKey !== JSON.parse(localStorage.getItem('userKey'))
) {
return state;
}