diff --git a/apiserver/plane/authentication/adapter/error.py b/apiserver/plane/authentication/adapter/error.py index aefceb3eb..47dbc8e8a 100644 --- a/apiserver/plane/authentication/adapter/error.py +++ b/apiserver/plane/authentication/adapter/error.py @@ -25,9 +25,12 @@ AUTHENTICATION_ERROR_CODES = { "INVALID_EMAIL_MAGIC_SIGN_IN": 5080, "MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED": 5085, # Both Sign in and Sign up for magic - "INVALID_MAGIC_CODE": 5090, - "EXPIRED_MAGIC_CODE": 5095, - "EMAIL_CODE_ATTEMPT_EXHAUSTED": 5100, + "INVALID_MAGIC_CODE_SIGN_IN": 5090, + "INVALID_MAGIC_CODE_SIGN_UP": 5092, + "EXPIRED_MAGIC_CODE_SIGN_IN": 5095, + "EXPIRED_MAGIC_CODE_SIGN_UP": 5097, + "EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN": 5100, + "EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP": 5102, # Oauth "GOOGLE_NOT_CONFIGURED": 5105, "GITHUB_NOT_CONFIGURED": 5110, diff --git a/apiserver/plane/authentication/provider/credentials/magic_code.py b/apiserver/plane/authentication/provider/credentials/magic_code.py index 9c199c4df..d53ce754a 100644 --- a/apiserver/plane/authentication/provider/credentials/magic_code.py +++ b/apiserver/plane/authentication/provider/credentials/magic_code.py @@ -13,6 +13,7 @@ from plane.authentication.adapter.error import ( AUTHENTICATION_ERROR_CODES, AuthenticationException, ) +from plane.db.models import User class MagicCodeProvider(CredentialAdapter): @@ -86,13 +87,23 @@ class MagicCodeProvider(CredentialAdapter): current_attempt = data["current_attempt"] + 1 if data["current_attempt"] > 2: - raise AuthenticationException( - error_code=AUTHENTICATION_ERROR_CODES[ - "EMAIL_CODE_ATTEMPT_EXHAUSTED" - ], - error_message="EMAIL_CODE_ATTEMPT_EXHAUSTED", - payload={"email": self.key}, - ) + email = str(self.key).replace("magic_", "", 1) + if User.objects.exists(email=email): + raise AuthenticationException( + error_code=AUTHENTICATION_ERROR_CODES[ + "EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN" + ], + error_message="EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN", + payload={"email": str(email)}, + ) + else: + raise AuthenticationException( + error_code=AUTHENTICATION_ERROR_CODES[ + "EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP" + ], + error_message="EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP", + payload={"email": self.key}, + ) value = { "current_attempt": current_attempt, @@ -132,18 +143,38 @@ class MagicCodeProvider(CredentialAdapter): ri.delete(self.key) return else: + email = str(self.key).replace("magic_", "", 1) + if User.objects.exists(email=email): + raise AuthenticationException( + error_code=AUTHENTICATION_ERROR_CODES[ + "INVALID_MAGIC_CODE_SIGN_IN" + ], + error_message="INVALID_MAGIC_CODE_SIGN_IN", + payload={"email": str(email)}, + ) + else: + raise AuthenticationException( + error_code=AUTHENTICATION_ERROR_CODES[ + "INVALID_MAGIC_CODE_SIGN_UP" + ], + error_message="INVALID_MAGIC_CODE_SIGN_UP", + payload={"email": str(email)}, + ) + else: + email = str(self.key).replace("magic_", "", 1) + if User.objects.exists(email=email): raise AuthenticationException( error_code=AUTHENTICATION_ERROR_CODES[ - "INVALID_MAGIC_CODE" + "EXPIRED_MAGIC_CODE_SIGN_IN" ], - error_message="INVALID_MAGIC_CODE", + error_message="EXPIRED_MAGIC_CODE_SIGN_IN", + payload={"email": str(email)}, + ) + else: + raise AuthenticationException( + error_code=AUTHENTICATION_ERROR_CODES[ + "EXPIRED_MAGIC_CODE_SIGN_UP" + ], + error_message="EXPIRED_MAGIC_CODE_SIGN_UP", payload={"email": str(email)}, ) - else: - magic_key = str(self.key) - email = magic_key.replace("magic_", "", 1) - raise AuthenticationException( - error_code=AUTHENTICATION_ERROR_CODES["EXPIRED_MAGIC_CODE"], - error_message="EXPIRED_MAGIC_CODE", - payload={"email": str(email)}, - ) diff --git a/space/components/account/auth-forms/auth-root.tsx b/space/components/account/auth-forms/auth-root.tsx index 5be59c5b6..b0c676fbf 100644 --- a/space/components/account/auth-forms/auth-root.tsx +++ b/space/components/account/auth-forms/auth-root.tsx @@ -49,19 +49,34 @@ export const AuthRoot: FC = observer(() => { if (error_code) { const errorhandler = authErrorHandler(error_code?.toString() as EAuthenticationErrorCodes); if (errorhandler) { + if (errorhandler.code === EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_IN) { + setAuthMode(EAuthModes.SIGN_IN); + setAuthStep(EAuthSteps.PASSWORD); + } + if (errorhandler.code === EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_UP) { + setAuthMode(EAuthModes.SIGN_UP); + setAuthStep(EAuthSteps.PASSWORD); + } if ( [ - EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_IN, - EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_UP, + EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_IN, + EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_IN, + EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN, ].includes(errorhandler.code) - ) - setAuthStep(EAuthSteps.PASSWORD); - if ( - [EAuthenticationErrorCodes.INVALID_MAGIC_CODE, EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE].includes( - errorhandler.code - ) - ) + ) { + setAuthMode(EAuthModes.SIGN_IN); setAuthStep(EAuthSteps.UNIQUE_CODE); + } + if ( + [ + EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_UP, + EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_UP, + EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP, + ].includes(errorhandler.code) + ) { + setAuthMode(EAuthModes.SIGN_UP); + setAuthStep(EAuthSteps.UNIQUE_CODE); + } setErrorInfo(errorhandler); } } diff --git a/space/helpers/authentication.helper.tsx b/space/helpers/authentication.helper.tsx index 98b103f2e..e2be3c617 100644 --- a/space/helpers/authentication.helper.tsx +++ b/space/helpers/authentication.helper.tsx @@ -21,42 +21,57 @@ export enum EErrorAlertType { export enum EAuthenticationErrorCodes { // Global INSTANCE_NOT_CONFIGURED = "5000", - SIGNUP_DISABLED = "5001", - INVALID_PASSWORD = "5002", // Password strength validation - SMTP_NOT_CONFIGURED = "5007", - // email check - INVALID_EMAIL = "5012", - EMAIL_REQUIRED = "5013", + INVALID_EMAIL = "5005", + EMAIL_REQUIRED = "5010", + SIGNUP_DISABLED = "5015", + // Password strength + INVALID_PASSWORD = "5020", + SMTP_NOT_CONFIGURED = "5025", // Sign Up - USER_ACCOUNT_DEACTIVATED = "5019", - USER_ALREADY_EXIST = "5003", - REQUIRED_EMAIL_PASSWORD_SIGN_UP = "5015", - AUTHENTICATION_FAILED_SIGN_UP = "5006", - INVALID_EMAIL_SIGN_UP = "5017", - MAGIC_SIGN_UP_EMAIL_CODE_REQUIRED = "5023", + USER_ALREADY_EXIST = "5030", + AUTHENTICATION_FAILED_SIGN_UP = "5035", + REQUIRED_EMAIL_PASSWORD_SIGN_UP = "5040", + INVALID_EMAIL_SIGN_UP = "5045", + INVALID_EMAIL_MAGIC_SIGN_UP = "5050", + MAGIC_SIGN_UP_EMAIL_CODE_REQUIRED = "5055", // Sign In - USER_DOES_NOT_EXIST = "5004", - REQUIRED_EMAIL_PASSWORD_SIGN_IN = "5014", - AUTHENTICATION_FAILED_SIGN_IN = "5005", - INVALID_EMAIL_SIGN_IN = "5016", - MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED = "5022", - INVALID_EMAIL_MAGIC_SIGN_IN = "5018", - // Both Sign in and Sign up - INVALID_MAGIC_CODE = "5008", - EXPIRED_MAGIC_CODE = "5009", + USER_ACCOUNT_DEACTIVATED = "5019", + USER_DOES_NOT_EXIST = "5060", + AUTHENTICATION_FAILED_SIGN_IN = "5065", + REQUIRED_EMAIL_PASSWORD_SIGN_IN = "5070", + INVALID_EMAIL_SIGN_IN = "5075", + INVALID_EMAIL_MAGIC_SIGN_IN = "5080", + MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED = "5085", + // Both Sign in and Sign up for magic + INVALID_MAGIC_CODE_SIGN_IN = "5090", + INVALID_MAGIC_CODE_SIGN_UP = "5092", + EXPIRED_MAGIC_CODE_SIGN_IN = "5095", + EXPIRED_MAGIC_CODE_SIGN_UP = "5097", + EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN = "5100", + EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP = "5102", // Oauth - GOOGLE_NOT_CONFIGURED = "5010", - GITHUB_NOT_CONFIGURED = "5011", - GOOGLE_OAUTH_PROVIDER_ERROR = "5021", - GITHUB_OAUTH_PROVIDER_ERROR = "5020", + GOOGLE_NOT_CONFIGURED = "5105", + GITHUB_NOT_CONFIGURED = "5110", + GOOGLE_OAUTH_PROVIDER_ERROR = "5115", + GITHUB_OAUTH_PROVIDER_ERROR = "5120", // Reset Password - INVALID_PASSWORD_TOKEN = "5024", - EXPIRED_PASSWORD_TOKEN = "5025", + INVALID_PASSWORD_TOKEN = "5125", + EXPIRED_PASSWORD_TOKEN = "5130", // Change password - INCORRECT_OLD_PASSWORD = "5026", - INVALID_NEW_PASSWORD = "5027", - // set password - PASSWORD_ALREADY_SET = "5028", // used in the onboarding and set password page + INCORRECT_OLD_PASSWORD = "5135", + MISSING_PASSWORD = "5138", + INVALID_NEW_PASSWORD = "5140", + // set passowrd + PASSWORD_ALREADY_SET = "5145", + // Admin + ADMIN_ALREADY_EXIST = "5150", + REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME = "5155", + INVALID_ADMIN_EMAIL = "5160", + INVALID_ADMIN_PASSWORD = "5165", + REQUIRED_ADMIN_EMAIL_PASSWORD = "5170", + ADMIN_AUTHENTICATION_FAILED = "5175", + ADMIN_USER_ALREADY_EXIST = "5180", + ADMIN_USER_DOES_NOT_EXIST = "5185", } export type TAuthErrorInfo = { @@ -105,7 +120,7 @@ const errorCodeMessages: { Your account is already registered.  Sign In @@ -129,12 +144,15 @@ const errorCodeMessages: { title: `Email and code required`, message: () => `Email and code required. Please try again.`, }, + [EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_UP]: { + title: `Invalid email`, + message: () => `Invalid email. Please try again.`, + }, // sign in - [EAuthenticationErrorCodes.USER_ACCOUNT_DEACTIVATED]: { title: `User account deactivated`, - message: () =>
Your account is deactivated. Please reach out to support@plane.so
, + message: () =>
Your account is deactivated. Contact support@plane.so.
, }, [EAuthenticationErrorCodes.USER_DOES_NOT_EXIST]: { @@ -174,11 +192,27 @@ const errorCodeMessages: { }, // Both Sign in and Sign up - [EAuthenticationErrorCodes.INVALID_MAGIC_CODE]: { + [EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_IN]: { title: `Authentication failed`, message: () => `Invalid magic code. Please try again.`, }, - [EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE]: { + [EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_UP]: { + title: `Authentication failed`, + message: () => `Invalid magic code. Please try again.`, + }, + [EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_IN]: { + title: `Expired magic code`, + message: () => `Expired magic code. Please try again.`, + }, + [EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_UP]: { + title: `Expired magic code`, + message: () => `Expired magic code. Please try again.`, + }, + [EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN]: { + title: `Expired magic code`, + message: () => `Expired magic code. Please try again.`, + }, + [EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP]: { title: `Expired magic code`, message: () => `Expired magic code. Please try again.`, }, @@ -212,6 +246,10 @@ const errorCodeMessages: { }, // Change password + [EAuthenticationErrorCodes.MISSING_PASSWORD]: { + title: `Password required`, + message: () => `Password required. Please try again.`, + }, [EAuthenticationErrorCodes.INCORRECT_OLD_PASSWORD]: { title: `Incorrect old password`, message: () => `Incorrect old password. Please try again.`, @@ -226,26 +264,87 @@ const errorCodeMessages: { title: `Password already set`, message: () => `Password already set. Please try again.`, }, + + // admin + [EAuthenticationErrorCodes.ADMIN_ALREADY_EXIST]: { + title: `Admin already exists`, + message: () => `Admin already exists. Please try again.`, + }, + [EAuthenticationErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME]: { + title: `Email, password and first name required`, + message: () => `Email, password and first name required. Please try again.`, + }, + [EAuthenticationErrorCodes.INVALID_ADMIN_EMAIL]: { + title: `Invalid admin email`, + message: () => `Invalid admin email. Please try again.`, + }, + [EAuthenticationErrorCodes.INVALID_ADMIN_PASSWORD]: { + title: `Invalid admin password`, + message: () => `Invalid admin password. Please try again.`, + }, + [EAuthenticationErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD]: { + title: `Email and password required`, + message: () => `Email and password required. Please try again.`, + }, + [EAuthenticationErrorCodes.ADMIN_AUTHENTICATION_FAILED]: { + title: `Authentication failed`, + message: () => `Authentication failed. Please try again.`, + }, + [EAuthenticationErrorCodes.ADMIN_USER_ALREADY_EXIST]: { + title: `Admin user already exists`, + message: () => ( +
+ Admin user already exists.  + + Sign In + +  now. +
+ ), + }, + [EAuthenticationErrorCodes.ADMIN_USER_DOES_NOT_EXIST]: { + title: `Admin user does not exist`, + message: () => ( +
+ Admin user does not exist.  + + Sign In + +  now. +
+ ), + }, }; export const authErrorHandler = ( errorCode: EAuthenticationErrorCodes, email?: string | undefined ): TAuthErrorInfo | undefined => { - const toastAlertErrorCodes = [ + const bannerAlertErrorCodes = [ + EAuthenticationErrorCodes.INSTANCE_NOT_CONFIGURED, + EAuthenticationErrorCodes.INVALID_EMAIL, + EAuthenticationErrorCodes.EMAIL_REQUIRED, EAuthenticationErrorCodes.SIGNUP_DISABLED, EAuthenticationErrorCodes.INVALID_PASSWORD, EAuthenticationErrorCodes.SMTP_NOT_CONFIGURED, - EAuthenticationErrorCodes.INVALID_EMAIL, - EAuthenticationErrorCodes.EMAIL_REQUIRED, + EAuthenticationErrorCodes.USER_ALREADY_EXIST, EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_UP, + EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_UP, EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_UP, + EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_UP, EAuthenticationErrorCodes.MAGIC_SIGN_UP_EMAIL_CODE_REQUIRED, + EAuthenticationErrorCodes.USER_DOES_NOT_EXIST, EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_IN, + EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_IN, EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_IN, EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_IN, - EAuthenticationErrorCodes.INVALID_MAGIC_CODE, - EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE, + EAuthenticationErrorCodes.MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED, + EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_IN, + EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_UP, + EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_IN, + EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_UP, + EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN, + EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP, EAuthenticationErrorCodes.GOOGLE_NOT_CONFIGURED, EAuthenticationErrorCodes.GITHUB_NOT_CONFIGURED, EAuthenticationErrorCodes.GOOGLE_OAUTH_PROVIDER_ERROR, @@ -255,25 +354,17 @@ export const authErrorHandler = ( EAuthenticationErrorCodes.INCORRECT_OLD_PASSWORD, EAuthenticationErrorCodes.INVALID_NEW_PASSWORD, EAuthenticationErrorCodes.PASSWORD_ALREADY_SET, - ]; - const bannerAlertErrorCodes = [ - EAuthenticationErrorCodes.INSTANCE_NOT_CONFIGURED, - EAuthenticationErrorCodes.USER_ALREADY_EXIST, - EAuthenticationErrorCodes.USER_DOES_NOT_EXIST, - EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_UP, - EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_IN, - EAuthenticationErrorCodes.MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED, + EAuthenticationErrorCodes.ADMIN_ALREADY_EXIST, + EAuthenticationErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD_FIRST_NAME, + EAuthenticationErrorCodes.INVALID_ADMIN_EMAIL, + EAuthenticationErrorCodes.INVALID_ADMIN_PASSWORD, + EAuthenticationErrorCodes.REQUIRED_ADMIN_EMAIL_PASSWORD, + EAuthenticationErrorCodes.ADMIN_AUTHENTICATION_FAILED, + EAuthenticationErrorCodes.ADMIN_USER_ALREADY_EXIST, + EAuthenticationErrorCodes.ADMIN_USER_DOES_NOT_EXIST, EAuthenticationErrorCodes.USER_ACCOUNT_DEACTIVATED, ]; - if (toastAlertErrorCodes.includes(errorCode)) - return { - type: EErrorAlertType.TOAST_ALERT, - code: errorCode, - title: errorCodeMessages[errorCode]?.title || "Error", - message: errorCodeMessages[errorCode]?.message(email) || "Something went wrong. Please try again.", - }; - if (bannerAlertErrorCodes.includes(errorCode)) return { type: EErrorAlertType.BANNER_ALERT, diff --git a/web/components/account/auth-forms/auth-root.tsx b/web/components/account/auth-forms/auth-root.tsx index 4e4d6be24..5ac9fd011 100644 --- a/web/components/account/auth-forms/auth-root.tsx +++ b/web/components/account/auth-forms/auth-root.tsx @@ -58,9 +58,14 @@ export const AuthRoot: FC = observer((props) => { ) setAuthStep(EAuthSteps.PASSWORD); if ( - [EAuthenticationErrorCodes.INVALID_MAGIC_CODE, EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE].includes( - errorhandler.code - ) + [ + EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_IN, + EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_UP, + EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_IN, + EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_UP, + EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN, + EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP, + ].includes(errorhandler.code) ) setAuthStep(EAuthSteps.UNIQUE_CODE); setErrorInfo(errorhandler); diff --git a/web/helpers/authentication.helper.tsx b/web/helpers/authentication.helper.tsx index 3de5132f7..f6bbe7788 100644 --- a/web/helpers/authentication.helper.tsx +++ b/web/helpers/authentication.helper.tsx @@ -53,9 +53,12 @@ export enum EAuthenticationErrorCodes { INVALID_EMAIL_MAGIC_SIGN_IN = "5080", MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED = "5085", // Both Sign in and Sign up for magic - INVALID_MAGIC_CODE = "5090", - EXPIRED_MAGIC_CODE = "5095", - EMAIL_CODE_ATTEMPT_EXHAUSTED = "5100", + INVALID_MAGIC_CODE_SIGN_IN = "5090", + INVALID_MAGIC_CODE_SIGN_UP = "5092", + EXPIRED_MAGIC_CODE_SIGN_IN = "5095", + EXPIRED_MAGIC_CODE_SIGN_UP = "5097", + EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN = "5100", + EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP = "5102", // Oauth GOOGLE_NOT_CONFIGURED = "5105", GITHUB_NOT_CONFIGURED = "5110", @@ -199,15 +202,27 @@ const errorCodeMessages: { }, // Both Sign in and Sign up - [EAuthenticationErrorCodes.INVALID_MAGIC_CODE]: { + [EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_IN]: { title: `Authentication failed`, message: () => `Invalid magic code. Please try again.`, }, - [EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE]: { + [EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_UP]: { + title: `Authentication failed`, + message: () => `Invalid magic code. Please try again.`, + }, + [EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_IN]: { title: `Expired magic code`, message: () => `Expired magic code. Please try again.`, }, - [EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED]: { + [EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_UP]: { + title: `Expired magic code`, + message: () => `Expired magic code. Please try again.`, + }, + [EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN]: { + title: `Expired magic code`, + message: () => `Expired magic code. Please try again.`, + }, + [EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP]: { title: `Expired magic code`, message: () => `Expired magic code. Please try again.`, }, @@ -334,9 +349,12 @@ export const authErrorHandler = ( EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_IN, EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_IN, EAuthenticationErrorCodes.MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED, - EAuthenticationErrorCodes.INVALID_MAGIC_CODE, - EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE, - EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED, + EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_IN, + EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_UP, + EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_IN, + EAuthenticationErrorCodes.EXPIRED_MAGIC_CODE_SIGN_UP, + EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN, + EAuthenticationErrorCodes.EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_UP, EAuthenticationErrorCodes.GOOGLE_NOT_CONFIGURED, EAuthenticationErrorCodes.GITHUB_NOT_CONFIGURED, EAuthenticationErrorCodes.GOOGLE_OAUTH_PROVIDER_ERROR,