-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
OAuth login flow replaces location after "signedIn" event is dispatched #13530
Comments
Hello @mkalam-alami. Amplify will clear any We are tracking this issue here. |
Hi @israx, thanks for your answer. I confirm having explicit control over completion of the OAuth flow would resolve my problem. Just to clarify, my workflow is actually started by calling Hub.listen('auth', (data) => {
if (data.payload.event === 'customOAuthState') {
this.customState = data.payload.data;
} else if (data.payload.event === 'signedIn') {
setTimeout(() => { // ensure callback is triggered after Amplify cleanup
history.replaceState({}, '', this.customState); // restore the requested URL
})
}
}); I suspect users typically do not encounter this behavior because of relying on Hub.listen('core', async (data) => {
if (data.payload.event === 'configure') {
try {
await getCurrentUser();
history.replaceState({}, '', this.customState); // restore the requested URL
} catch (error) {
// ... signInWithRedirect()
}
}
});
Hub.listen('auth', (data) => {
if (data.payload.event === 'customOAuthState') {
this.customState = data.payload.data;
}
}); |
Thank you for providing all the context. I think we can change the order of operations and clear query params before dispatching the events. Let me bring this issue to the team. |
Marking this as a bug in v6, as v5 of Amplify does not have this issue and will clear the window history before dispatching the hub events. |
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
None
Environment information
Describe the bug
When OAuth sign in flow completes and the "signedIn" event is dispatched, the flow has actually not totally completed, and the library replaces the browser URL which may clash with application behavior.
Expected behavior
That the "signedIn" event is dispatched when the OAuth flow is fully completed, with no further actions from the Amplify library. This behavior allows applications to take control on the redirection, in my case overriding the static redirect URL with a dynamic route.
Reproduction steps
signInWithRedirect()
See
completeOAuthFlow.ts
behavior :amplify-js/packages/auth/src/providers/cognito/utils/oauth/completeOAuthFlow.ts
Line 251 in e6c5f60
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: