Skip to content

Expire user session when access token expires - #112

Draft
Naokimi wants to merge 1 commit into
mainfrom
expire-user-session-when-access_token-expires
Draft

Expire user session when access token expires#112
Naokimi wants to merge 1 commit into
mainfrom
expire-user-session-when-access_token-expires

Conversation

@Naokimi

@Naokimi Naokimi commented Jun 20, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

stale Bot commented Nov 11, 2022

Copy link
Copy Markdown

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