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

Expire user session when access token expires #112

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Naokimi
Copy link
Contributor

@Naokimi Naokimi commented Jun 20, 2022

In a previous commit we setup to have the AddAddressesToBolt be called
asynchronously via a Job. However, when the first access_token expires
then new one doesn't have write access anymore so the Job fails. To
solve this we are adding a check for the expiration time and signing out
the user, to force them to get a fresh token with write access.

To improve the UX, we are moving this step to before delivery (to avoid
signing out a user right at the end of the checkout flow).

Requires nebulab/omniauth-bolt#5

@Naokimi Naokimi self-assigned this Jun 20, 2022

private

def session_refreshed_or_expired?
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering we are not refreshing the access_token anymore, maybe it will be better to rename it to write_access_token_expired? or something like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 57a97b7

def before_delivery
if session_refreshed_or_expired?
Spree::UserLastUrlStorer.new(self).store_location
sign_out(spree_current_user)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't require redirecting the user to sign_out page? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when I tested it it redirected automatically

@Naokimi Naokimi force-pushed the expire-user-session-when-access_token-expires branch from 03b7a9a to 57a97b7 Compare June 21, 2022 02:02
In a previous commit we setup to have the AddAddressesToBolt be called
asynchronously via a Job. However, when the first access_token expires
then new one doesn't have write access anymore so the Job fails. To
solve this we are adding a check for the expiration time and signing out
the user, to force them to get a fresh token with write access.

To improve the UX, we are moving this step to before delivery (to avoid
signing out a user right at the end of the checkout flow).
@Naokimi Naokimi force-pushed the expire-user-session-when-access_token-expires branch from 57a97b7 to dd9b5a5 Compare June 21, 2022 02:02
@stale
Copy link

stale bot commented Nov 11, 2022

This issue has been automatically marked as stale because it has not had recent activity. It might be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 11, 2022
@gsmendoza gsmendoza removed the stale label Nov 11, 2022
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