-
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
PreSignUp Trigger error not forwarding to signInWithRedirects_failure #14063
Comments
Hello, @bilalAlgoace 👋. This looks similar to what's being captured in issue #13436 where there's possibly a race condition where the Hub event is dispatched before the useEffect hook is called. Can you see the advice within this comment to see if moving the |
@cwomack Thank you it works for me. 👍 |
Glad to hear, @bilalAlgoace and thanks for following up! |
@cwomack now i am facing a issue on social authentications i am trying to sigin with google it is throw error: { error message : "User cancelled OAuth flow." The reason I think is that in cogtino my redirect callbackurl is: http://localhost:3000/ and I have added a protection layer in my app that if user is not authenticated it should get redirected to http://localhost:3000/login. That's why it is showing this: "User cancelled OAuth flow" error. but It is only happening with social logins and if i am using normal signin with email password it is working perfect. and If I changed my cogtino redirect callbackurl is: http://localhost:3000/login which doesn't need any authentication in my app it is also working properly and is signing in normally with social logins too. @cwomack if you can please guide me in this too. |
@bilalAlgoace, it's possible that the added protection layer is impacting the behavior here when returning back from the Cognito Hosted UI. Can you provide a little more detail as to what's happening there (or share the relevant code)? But you should be able to keep using the redirect callback URL of http://localhost:3000/login (which should avoid the auth protection step) and then wait for the user session to be available via a call to the |
@cwomack yeah I did the same thing you are telling in the comment and it is working perfectly. |
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Amplify CLI
Environment information
Describe the bug
I have created a preSignUp trigger which checks whether the email is registered or not and if registered then do not allow user to register that email this is working fine with simple email and password process and throwing error of user already exists but with i am using signInWithRedirects it is showing error in search params like this:
http://localhost:3000/signup?error_description=PreSignUp+failed+with+error+User+already+exists..+&state=lymVlSL5AV0pIeORuFFVDdSe1r3Wh7zx&error=invalid_request
but not forwarding any error in signInWIthRedirects_failure
I am using Next js 14 app router
but this code is working in Reavt Native and showing proper error in signInWIthRedirects_failure
Expected behavior
It should show error in signInWIthRedirects_failure
Reproduction steps
I am using signInWithRedirects for social logins with amplify
Code Snippet
Log output
aws-exports.js
const awsmobile = {
"aws_project_region": "us-east-2",
"aws_cognito_identity_pool_id": "us-east-2xxxxxxxxxxxxxxx",
"aws_cognito_region": "us-east-2",
"aws_user_pools_id": "us-east-2_xxxxxxxxxxxxxxxxx",
"aws_user_pools_web_client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"oauth": {
"domain": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"scope": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
],
"redirectSignIn": "kwelta://,http://localhost:3000/signup",
"redirectSignOut": "kwelta://,http://localhost:3000/signin",
"responseType": "code"
},
"federationTarget": "COGNITO_USER_POOLS",
"aws_cognito_username_attributes": [
"EMAIL"
],
"aws_cognito_social_providers": [
"FACEBOOK",
"GOOGLE",
"APPLE"
],
"aws_cognito_signup_attributes": [
"EMAIL"
],
"aws_cognito_mfa_configuration": "OFF",
"aws_cognito_mfa_types": [
"SMS"
],
"aws_cognito_password_protection_settings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": []
},
"aws_cognito_verification_mechanisms": [
"EMAIL"
]
};
export default awsmobile;
Manual configuration
{
"aws_project_region": "us-east-2",
"aws_cognito_identity_pool_id": "us-east-2xxxxxxxxxxxxxxxxxxxxxxx",
"aws_cognito_region": "us-east-2",
"aws_user_pools_id": "us-east-2_xxxxxxxxxxxxx",
"aws_user_pools_web_client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"oauth": {
"domain": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"scope": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
],
"redirectSignIn": "kwelta://,http://localhost:3000/signup",
"redirectSignOut": "kwelta://,http://localhost:3000/signin",
"responseType": "code"
},
"federationTarget": "COGNITO_USER_POOLS",
"aws_cognito_authentication_flow_type": "CUSTOM_AUTH",
"aws_cognito_username_attributes": [
"EMAIL"
],
"aws_cognito_social_providers": [
"FACEBOOK",
"GOOGLE",
"APPLE"
],
"aws_cognito_signup_attributes": [
"EMAIL"
],
"aws_cognito_mfa_configuration": "OFF",
"aws_cognito_mfa_types": [
"SMS"
],
"aws_cognito_password_protection_settings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": []
},
"aws_cognito_verification_mechanisms": [
"EMAIL"
]
}
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: