-
Notifications
You must be signed in to change notification settings - Fork 364
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
[SDK-1739] Recover and logout when throwing invalid_grant on Refresh Token #668
Conversation
|
||
if (e.error === 'login_required') { | ||
_self.isAuthenticated = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This catches the login_required
in our playground, allowing us to reset the authentication state when needed based on the response from Auth0.
e.message && | ||
e.message.indexOf(INVALID_REFRESH_TOKEN_ERROR_MESSAGE) > -1 | ||
) { | ||
return await this._getTokenFromIFrame(options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces an additional request in Safari where we know up front it will return login_required
, while for other browsers it might still work.
I do not think the SDK is currently tracking which browsers can use iframe, nor do I think it should so I wonder what you think about this extra request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to leave it, we don't do browser detection for this elsewhere and it will work for other browsers that also block third-party cookies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just had a comment about the double if
statement.
src/Auth0Client.ts
Outdated
if ( | ||
e.message && | ||
e.message.indexOf(INVALID_REFRESH_TOKEN_ERROR_MESSAGE) > -1 | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can unify this if
block with the conditional above it, rather than having two if's? Feels like we could do it with an or expression.
Description
This PR ensures the SDK can recover from being instantiated using an invalid Refresh Token.
getTokenSilently
with RefreshTokens and the Refresh Token is expired:invalid_grant
error is caught and used to fallback tologinWithIFrame
login_required
error.References
Closes #654
#449
Testing
Checklist
master