Skip to content

Commit

Permalink
Merge pull request #3601 from gibkigonzo/bugfix/logout-user-if-error-…
Browse files Browse the repository at this point in the history
…occurs

3588 clear user data if error occurs while login
  • Loading branch information
patzick committed Sep 24, 2019
2 parents 5c251dc + ecc9e9a commit 6115522
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Prevent caching storage instance in plugin module scope - @gibkigonzo (#3571)
- Fixed incorrect image sizes in related section on product page - @andrzejewsky (#3590)
- Fix typo on default language - @lorenaramonda (#3076)
- clear user data if error occurs while login - @gibkigonzo (#3588)
- Fix loading bestsellers on 404 error page - @andrzejewsky (#3540)

### Changed / Improved
Expand Down
11 changes: 8 additions & 3 deletions core/modules/user/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ const actions: ActionTree<UserState, RootState> = {
userHooksExecutors.afterUserAuthorize(resp)

if (resp.code === 200) {
await dispatch('resetUserInvalidateLock', {}, { root: true })
commit(types.USER_TOKEN_CHANGED, { newToken: resp.result, meta: resp.meta }) // TODO: handle the "Refresh-token" header
await dispatch('sessionAfterAuthorized', { refresh: true, useCache: false })
try {
await dispatch('resetUserInvalidateLock', {}, { root: true })
commit(types.USER_TOKEN_CHANGED, { newToken: resp.result, meta: resp.meta }) // TODO: handle the "Refresh-token" header
await dispatch('sessionAfterAuthorized', { refresh: true, useCache: false })
} catch (err) {
await dispatch('clearCurrentUser')
throw new Error(err)
}
}

return resp
Expand Down

0 comments on commit 6115522

Please sign in to comment.