From 905db1d29b94fd2f1251122e1905cea4ef87a537 Mon Sep 17 00:00:00 2001 From: martin-mfg <2026226+martin-mfg@users.noreply.github.com> Date: Wed, 7 Jan 2026 12:10:40 +0100 Subject: [PATCH] fix logout problems --- frontend/frontend/src/api/user.js | 4 +++- frontend/frontend/src/redux/reducers/user.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/frontend/src/api/user.js b/frontend/frontend/src/api/user.js index 87baf7d8..f89585e7 100644 --- a/frontend/frontend/src/api/user.js +++ b/frontend/frontend/src/api/user.js @@ -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; diff --git a/frontend/frontend/src/redux/reducers/user.js b/frontend/frontend/src/redux/reducers/user.js index b42b3564..37d1d9a4 100644 --- a/frontend/frontend/src/redux/reducers/user.js +++ b/frontend/frontend/src/redux/reducers/user.js @@ -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; }