Improve sign-in error handling
This commit is contained in:
parent
9aa6546b90
commit
3281bd42f9
@ -2,6 +2,7 @@
|
||||
|
||||
import {
|
||||
KEY_CALLBACK_URL,
|
||||
KEY_CREDENTIALS_CALLBACK_ROUTE_ERROR_URL,
|
||||
KEY_CREDENTIALS_SIGN_IN_ERROR,
|
||||
KEY_CREDENTIALS_SIGN_IN_ERROR_URL,
|
||||
auth,
|
||||
@ -21,7 +22,9 @@ export const signInAction = async (
|
||||
} catch (error) {
|
||||
if (
|
||||
`${error}`.includes(KEY_CREDENTIALS_SIGN_IN_ERROR) ||
|
||||
`${error}`.includes(KEY_CREDENTIALS_SIGN_IN_ERROR_URL)
|
||||
`${error}`.includes(KEY_CREDENTIALS_SIGN_IN_ERROR_URL) ||
|
||||
// New error thrown in next-auth 5.0.0-beta.19 for incorrect credentials
|
||||
`${error}`.includes(KEY_CREDENTIALS_CALLBACK_ROUTE_ERROR_URL)
|
||||
) {
|
||||
// Return credentials error to display on sign-in page.
|
||||
return KEY_CREDENTIALS_SIGN_IN_ERROR;
|
||||
|
||||
@ -5,6 +5,8 @@ import Credentials from 'next-auth/providers/credentials';
|
||||
export const KEY_CREDENTIALS_SIGN_IN_ERROR = 'CredentialsSignin';
|
||||
export const KEY_CREDENTIALS_SIGN_IN_ERROR_URL =
|
||||
'https://errors.authjs.dev#credentialssignin';
|
||||
export const KEY_CREDENTIALS_CALLBACK_ROUTE_ERROR_URL =
|
||||
'https://errors.authjs.dev#callbackrouteerror';
|
||||
export const KEY_CALLBACK_URL = 'callbackUrl';
|
||||
|
||||
export const {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user