-
Notifications
You must be signed in to change notification settings - Fork 7
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
Authentication fixes #92
Conversation
* Use constant for storage field prefix * Use localStorage instead of sessionStorage so the token is persisted through browser sessions * Clean stale state entries more often * Perform silent renew if the token is already expired on user load
mgr.signinSilent().then((_, reject) => { | ||
if (reject) { | ||
mgr.clearStaleState(store, 0) | ||
return null | ||
} | ||
return user.access_token | ||
}) | ||
} else { | ||
return user.access_token | ||
} |
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.
By the way, let me know if you want me to switch this to use await
.
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.
That would be nice 👍
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.
Keep in mind this would require a couple more functions to become async
, including initApp
, are you sure the added complexity is worth it?
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.
Probably something for a different PR 😅
Thanks for taking care! Please also add a changelog item in |
Hi ownClouders! 👋
While working in integrating ownCloud in Indico via the file-picker, I found some problems with the authentication.
Everything was working fine as long as the access token was kept valid. But if I let the token expire and then tried to open the file-picker again, it froze in the loading spinner. Turns out it was not trying to issue a renewal after loading the user, and so, no valid token is available to authenticate.
To solve this, I added an expiry check and token renewal when the user is loaded.
While at it, I also moved the token storage to
localStorage
instead ofsessionStorage
. This enables persistence even if the user closes the browser. To mitigate possible stale tokens, I increased the frequency of stale entry cleanup (whenever an error occurs).Let me know if you see any problems in that. Also, feel free to ask me to split the PR if you think it's worth it.
Cheers!