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

fix: Show login modal when user session expires. #2541

Merged
merged 11 commits into from
Sep 22, 2021

Conversation

victorgcramos
Copy link
Member

@victorgcramos victorgcramos commented Aug 17, 2021

Close #2538

This diff fixes an issue that reported the absence of some login modal
when some user submits a proposal with an expired session.

Dependencies

Depends on decred/pi-ui#369

UI Changes Screenshot

Screen Shot 2021-08-17 at 5 36 04 PM

@victorgcramos victorgcramos force-pushed the 2538-expired-session-bug branch 2 times, most recently from 1fd712a to 6382e5e Compare August 20, 2021 23:55
@victorgcramos victorgcramos changed the title fix: Display login option on proposal submission session error. fix: Display login modal when user session expires. Aug 20, 2021
@victorgcramos
Copy link
Member Author

Improved this PR to comprise all possible expired sessions errors, by improving the SessionChecker HOC to display the login modal when some user session expires.

This commit improves the user session control, by displaying the login
modal when some user session expires.
Copy link
Member

@lukebp lukebp left a comment

Choose a reason for hiding this comment

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

This currently displays the modal as soon as the session expires. This is not quite what we want. The modal should be displayed once the session expires AND the user attempts to access a route that requires the user to be logged in (ex. proposal submission, comment submission, etc).

@victorgcramos
Copy link
Member Author

@lukebp handling all requests and displaying the login modal for them will require an extensive refactor because we need to change the way we handle auth errors on forms and other private actions. The Login modal display is an async procedure, so all 403 errors would be displayed in the form error message before the login modal shows up, just like other response errors.

I opted to go for this approach because this way we can avoid those syncing problems mentioned above. After talking to @tiagoalvesdulce, we both agreed that it should be included in the new architecture.

@lukebp
Copy link
Member

lukebp commented Aug 31, 2021

Ok, that's fine. We definitely don't want to display the login modal as soon as the session expires though. We've done this before and it was very annoying for users because they would leave tabs open when reading proposals and would constantly have to log back in.

We have two options:

  1. Hardcode the modal behavior to pop up when the session has expired for certain routes. Probably just the proposal submission and comment submission route for now.

or

  1. Do nothing for now and wait for the new architecture.

Thoughts?
@tiagoalvesdulce @victorgcramos

@victorgcramos
Copy link
Member Author

1 for me is the best.

@lukebp
Copy link
Member

lukebp commented Aug 31, 2021

Ok, go with option 1 then.

@tiagoalvesdulce
Copy link
Member

I'm OK with option 1.

Copy link
Member

@lukebp lukebp left a comment

Choose a reason for hiding this comment

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

tACK

@lukebp
Copy link
Member

lukebp commented Sep 16, 2021

@victorgcramos can you fix the merge conflicts?

This needs final approval from @tiagoalvesdulce.

@victorgcramos
Copy link
Member Author

Let's wait for #2549 first.

Copy link
Member

@tiagoalvesdulce tiagoalvesdulce left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@amass01 amass01 left a comment

Choose a reason for hiding this comment

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

Good job, tested and works fine.

I suggest we show the modal also on comment vote.
Also, added a minor inline comment.

password: "password"
};
cy.login(user);
cy.intercept("/api/ticketvote/v1/inventory").as("inventory");
Copy link
Member

Choose a reason for hiding this comment

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

want to add this as a middleware ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd wait until the mocked api structure is done to mock all requests. This is just an alias without any response changes.

Copy link
Member

Choose a reason for hiding this comment

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

Sweet

Copy link
Member

@amass01 amass01 left a comment

Choose a reason for hiding this comment

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

nice work, LGTM!

@lukebp
Copy link
Member

lukebp commented Sep 22, 2021

Please update your commit message. Same comment that I said here.

#2568 (comment)

@victorgcramos victorgcramos changed the title fix: Display login modal when user session expires. fix: Show login modal when user session expires. Sep 22, 2021
@lukebp lukebp merged commit 50ece8c into decred:master Sep 22, 2021
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.

Expired session bug.
4 participants