Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@psrok1
Copy link
Member

@psrok1 psrok1 commented Jun 8, 2021

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running the project, and testing changed functionality (if applicable)

What is the current behaviour?

Multiple MWDB users are reporting problems with unexpected session expiration during normal usage or after leaving the MWDB opened for a longer time.

image

This is pretty annoying and is caused by few flaws in client-side code that handles authentication.

What is the new behaviour?

This PR applies few fixes:

  • Webapp periodically refreshes the session to prevent expiration when tab is opened for a longer time. Unfortunately, that mechanism caused the opposite effect, because there are huge chances that some of /api/refresh requests will fail after multiple periodic calls, causing the logout. Changed handling of that situation from logout to silent error reported in console. If session has really expired, user will be notified anyway via HTTP 401 handling.

  • There was a race-condition on mount: some API requests were sent on component mount before the authorization token is set in Axios request headers. That situation results in HTTP 401 and logout even if correct session token is available in localStorage. Added useAxiosEffect to setup interceptors and headers as a part of initial render (like componentWillMount), so Axios will be set-up first.

  • getStoredAuthSession haven't checked for empty user key in localStorage, which results in error reported in dev console. Added proper check.

image

Test plan

  • Check if problem is fixed and there is no regression

@psrok1 psrok1 added this to the 2.3.0 milestone Jun 8, 2021
@psrok1 psrok1 requested a review from KWMORALE June 8, 2021 18:20
Copy link
Contributor

@msm-code msm-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I understand all the implications of this, but LGTM

@psrok1 psrok1 merged commit 273f236 into master Jun 9, 2021
@psrok1 psrok1 deleted the fix/premature-session-expiration branch July 16, 2021 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants