From c52923d52a4415545bd76d159fecf2db7ddeb5fc Mon Sep 17 00:00:00 2001 From: Ivar Derksen Date: Tue, 20 Sep 2022 16:48:26 +0200 Subject: [PATCH] Fix: userdata is not fetched when logging in via registration email --- src/store/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index b8f0b81..4eb780a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -129,7 +129,6 @@ function handleTokenLogin({ dispatch }) { .then((res) => { if (res.status !== 204) throw res.status; dispatch({ type: 'loggedIn' }); - dispatch({ type: 'startUpdateInfo' }); }) .catch((err) => { dispatch({ type: 'raiseError', errorMessage: `Error while logging in with token: ${err}` }); @@ -196,7 +195,6 @@ function handleVerifySession({ dispatch }) { .then((res) => { if (res === 'ok') { dispatch({ type: 'loggedIn' }); - dispatch({ type: 'startUpdateInfo' }); } else if (res === 'expired') { dispatch({ type: 'loggedOut' }); } else { @@ -211,6 +209,15 @@ function handleVerifySession({ dispatch }) { }; } +function handleLoggedIn({ dispatch }) { + return (next) => (action) => { + if (action.type === 'loggedIn') { + dispatch({ type: 'startUpdateInfo' }); + } + return next(action); + }; +} + function handleLogout({ dispatch }) { return (next) => (action) => { // When resolving an error, logout is performed without raising an error if it fails. @@ -254,6 +261,7 @@ export default function buildStore() { handleEmailLogin, handleRegistrationVerify, handleVerifySession, + handleLoggedIn, handleLogout ) );