Skip to content

Commit

Permalink
Merge pull request #25 from privacybydesign/post-registration-login-fix
Browse files Browse the repository at this point in the history
Fix: userdata is not fetched when logging in via registration email
  • Loading branch information
ivard authored Sep 26, 2022
2 parents a11b9ee + c52923d commit 985961f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}` });
Expand Down Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -254,6 +261,7 @@ export default function buildStore() {
handleEmailLogin,
handleRegistrationVerify,
handleVerifySession,
handleLoggedIn,
handleLogout
)
);
Expand Down

0 comments on commit 985961f

Please sign in to comment.