-
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
Error message not available to signInWithRedirect_failure in Hub #13842
Comments
@johnf, thanks for opening this issue with so much detail! Can you give a little more context on how you're using the error object? Are you using |
@cwomack It is directly related to the social linking in aws-amplify/amplify-cli#4427. You need to know what the error that was thrown in the trigger so you can perform an action. I have other use cases where I might Hub.listen('auth', async ({ payload }) => {
const { event } = payload;
switch (event) {
case 'signInWithRedirect_failure': {
const { error } = payload.data;
if (!error) {
Sentry.captureMessage('Unhandled signInWithRedirect_failure event', { extra: { event } });
console.error('Unhandled signInWithRedirect_failure event', JSON.stringify(payload, null, 2));
return;
}
const linkedMatch = error.message.match(/LINKED_EXTERNAL_USER_([^.]+)/);
if (linkedMatch) {
const provider = (linkedMatch[1].charAt(0).toUpperCase() +
linkedMatch[1].slice(1)) as SignInWithRedirectInput['provider'];
await handleFederatedSignIn(provider);
return;
}
if (error.message.match(/User is not enabled/)) {
Toast.show('This account is in the process of being deleted, please contact support', { type: 'error' });
return;
}
Toast.show('Unhandled Error: Please contact support for help.', { type: 'error' });
Sentry.captureMessage('Unhandled signInWithRedirect_failure event', { extra: { event } });
console.error('Unhandled signInWithRedirect_failure event', JSON.stringify(payload, null, 2));
return;
}
} |
@johnf, thanks for the reply. The This shouldn't require us to make any further code changes or consider this behavior to be a bug at this point. |
@cwomack Sorry for wasting time here; I was down a deep rabbit hole yesterday with the current race condition around Hub.listen and oAuth. Looking at this code with fresh eyes, it's obvious that it's superfluous. Thanks for your help! |
@johnf, thanks for following up and glad you're unblocked! |
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'm using next.js for authentication with Google
I have Cognito PreSignup trigger that creates a standard account if the user email doesn't exist and then returns an error
Similar to what is described in aws-amplify/amplify-cli#4427
This works fine in my React Native app, but on the web the path is different
It hits https://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/providers/cognito/utils/oauth/completeOAuthFlow.ts#L39-L44
the
error_message
gets passed tohttps://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/providers/cognito/utils/oauth/createOAuthError.ts#L8-L17
The message looks like it's being passed into the error but it us surfaced at
https://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/providers/cognito/utils/oauth/attempt
and then on to
https://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/providers/cognito/utils/oauth/handleFailure.ts#L19
The error message itself is lost.
I've fixed with this diff and can do a PR
Expected behavior
The error message from the backend exception is accessible in the Hub data
Reproduction steps
I can provide a repro if needed but it's basically
signInRedirect_withFailure
Code Snippet
// Put your code below this line.
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: