fix: improved 'use-identity-login' error message for users trying to signInn using different provider (#20582)

* improved 'use-identity-login' error message for users trying to signin using different provider

* passing original identity provider as query parameter

* Update packages/features/auth/lib/next-auth-options.ts

* passed different error names for different types of error

---------

Co-authored-by: romit <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: Tushar Bhatt <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-04-21 13:38:19 +00:00
1 parent d81b905ad7
commit d99ecde0e2
3 files changed
+34 -6

No files matched your search

@@ -950,7 +950,7 @@ export const getOptions = ({
return true;
}
} else if (existingUserWithEmail.identityProvider === IdentityProvider.CAL) {
return "/auth/error?error=use-password-login";
return `/auth/error?error=wrong-provider&provider=${existingUserWithEmail.identityProvider}`;
} else if (
existingUserWithEmail.identityProvider === IdentityProvider.GOOGLE &&
idP === IdentityProvider.SAML
@@ -971,8 +971,7 @@ export const getOptions = ({
return true;
}
}
return "/auth/error?error=use-identity-login";
return `auth/error?error=wrong-provider&provider=${existingUserWithEmail.identityProvider}`;
}
// Associate with organization if enabled by flag and idP is Google (for now)
@@ -1010,7 +1009,7 @@ export const getOptions = ({
}
} catch (err) {
log.error("Error creating a new user", err);
return "/auth/error?error=use-identity-login";
return `/auth/error?error=user-creation-error`;
}
}