amplify-js
amplify-js copied to clipboard
Ability to specify query parameters for logout URL when calling signOut()
Is this related to a new or existing framework?
React
Is this related to a new or existing API?
Authentication
Is this related to another service?
Cognito
Describe the feature you'd like to request
When the user gets logged out due to inactivity, it's particularly useful to save the page URL before redirecting him to logout page. This would allow him then to get back to where he left off when starting the new session.
Common practice to achieve this is to store the current URL as the query parameter and append that parameter to logout URL. For example, using auth0-js
:
- const returnTo = 'https://example.com/logout?saved_url=' + encodeURIComponent(location.href)
- auth0.logout({ returnTo })
- // after user logs in again - use
saved_url
query param
Amplify-js
.signOut()
does not support an option similar to returnTo
, so I request it here.
Describe the solution you'd like
Add an argument to signOut()
method that would allow overriding logout URL (or redirectSignOut
oath config in other words). Or at least allow appending query to logout URL
Describe alternatives you've considered
sessionStorage
is an alternative that would work in some cases. The problem is that according to RFC-2109 sessionStorage should be cleared when closing the page, so this won't work if the browser restarts before the user logs in again
Additional context
No response
Is this something that you'd be interested in working on?
- [ ] 👋 I may be able to implement this feature request
- [ ] ⚠️ This feature might incur a breaking change
Would be great to have this implemented. Is there a timeline on this?
Would love to see this as well! According the AWS Cognito docs, the logout endpoint supports a state
query param where this value could be passed in as so just exposing customState
to Auth.signOut
like you have for Auth.federatedSignIn
this is one of the most needed feature, very basic one, not sure how this is missed out. right now if there is slight change sigonout url, if just fails. Ideally it should allow the query parameters to be appended to logout_uri value when it is sent as url encoded.
Hi, we also need this feature. Is there a very rough prediction when it will be implemented? We are currently planning to implement a workaround, but maybe we just can wait.