Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PXP-7429): fix/workspaceLogout: added backup if api call fails to refresh user, … #804

Merged
merged 6 commits into from
Feb 15, 2021

Conversation

ocshawn
Copy link
Contributor

@ocshawn ocshawn commented Feb 12, 2021

Jira Ticket: PXP-7429

Bug Fixes

  • added backup if api call fails to refresh user
  • added listeners to iframe when on workspace page

@ocshawn ocshawn requested a review from mfshao February 12, 2021 23:12
Copy link
Collaborator

@mfshao mfshao left a comment

Choose a reason for hiding this comment

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

please address the travis issue before this PR can get merged

@@ -83,6 +83,9 @@ export class SessionMonitor {
if (response.type === 'UPDATE_POPUP') {
this.popupShown = true;
}
}).catch(() => {
// if API failed check if user is still logged in
this.notifyUserIfTheyAreNotLoggedIn();
Copy link
Collaborator

Choose a reason for hiding this comment

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

why logging out user at here? the logic was if it can reach refreshSession() then it means the user is still logged in and actively using the portal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the bug had to do with the user being logged out, but not alerted that they had been logged out, leading to other errors. this code checks if they are still logged in and if not alerts them, it does not log them out. I am still not 100% on how all of this code works if you do not think this check is needed i can remove

Copy link
Collaborator

@mfshao mfshao Feb 15, 2021

Choose a reason for hiding this comment

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

I think the bug was actually buried deeper in the logic flow: the notifyUserIfTheyAreNotLoggedIn function will make a call to the submission api and when it returns a 401 the portal assumes the user is logged out. But this will result in as the current behavior that for some times the popup showed up early while in other occassions some are shown up later.

This is mainly due to the fact that the access token in cookie is not updated until the pervious one has expired. After this fix uc-cdis/fence#874 is merged, both session token and access token will be updated.

For that case, I probably will test and change this logic flow back to let portal actively logout users. So this piece of code will probably be removed in my work. I'm okay will merging as is because I think it won't break things, just a FYI

The changes to the workspace code LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, thanks for looking over, im glad someone else was also looking into this

@ocshawn ocshawn requested a review from mfshao February 15, 2021 15:53
@ocshawn ocshawn merged commit 8ef3c1a into master Feb 15, 2021
@ocshawn ocshawn deleted the fix/workspaceLogout branch February 15, 2021 20:37
iframeContent.addEventListener('keypress', () => sessionMonitor.updateUserActivity(), false);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I've been looking at this, and did some tests today. This does not seem to work. @mfshao or @ocshawn can you please comment when/in which scenario this code works?

Copy link
Contributor

Choose a reason for hiding this comment

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

See also this for what I think should have been used: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage . And this PR which proposes a solution using "message" events: #1002

Copy link
Contributor

Choose a reason for hiding this comment

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

But maybe the context in which your code works is somehow different...not sure.

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.

3 participants