2024-05-08 17:31:20 +00:00
|
|
|
import { ReactNode } from "react";
|
|
|
|
import Link from "next/link";
|
2024-05-23 08:57:16 +00:00
|
|
|
// helpers
|
|
|
|
import { SUPPORT_EMAIL } from "./common.helper";
|
2024-05-08 17:31:20 +00:00
|
|
|
|
|
|
|
export enum EPageTypes {
|
|
|
|
INIT = "INIT",
|
|
|
|
PUBLIC = "PUBLIC",
|
|
|
|
NON_AUTHENTICATED = "NON_AUTHENTICATED",
|
|
|
|
ONBOARDING = "ONBOARDING",
|
|
|
|
AUTHENTICATED = "AUTHENTICATED",
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum EErrorAlertType {
|
|
|
|
BANNER_ALERT = "BANNER_ALERT",
|
|
|
|
TOAST_ALERT = "TOAST_ALERT",
|
|
|
|
INLINE_FIRST_NAME = "INLINE_FIRST_NAME",
|
|
|
|
INLINE_EMAIL = "INLINE_EMAIL",
|
|
|
|
INLINE_PASSWORD = "INLINE_PASSWORD",
|
|
|
|
INLINE_EMAIL_CODE = "INLINE_EMAIL_CODE",
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum EAuthenticationErrorCodes {
|
|
|
|
// Global
|
|
|
|
INSTANCE_NOT_CONFIGURED = "5000",
|
2024-05-20 06:53:48 +00:00
|
|
|
INVALID_EMAIL = "5005",
|
|
|
|
EMAIL_REQUIRED = "5010",
|
|
|
|
SIGNUP_DISABLED = "5015",
|
|
|
|
// Password strength
|
|
|
|
INVALID_PASSWORD = "5020",
|
|
|
|
SMTP_NOT_CONFIGURED = "5025",
|
2024-05-08 17:31:20 +00:00
|
|
|
// Sign Up
|
2024-05-20 06:53:48 +00:00
|
|
|
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",
|
2024-05-08 17:31:20 +00:00
|
|
|
// Sign In
|
2024-05-20 06:53:48 +00:00
|
|
|
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",
|
2024-05-08 17:31:20 +00:00
|
|
|
// Oauth
|
2024-05-20 06:53:48 +00:00
|
|
|
GOOGLE_NOT_CONFIGURED = "5105",
|
|
|
|
GITHUB_NOT_CONFIGURED = "5110",
|
|
|
|
GOOGLE_OAUTH_PROVIDER_ERROR = "5115",
|
|
|
|
GITHUB_OAUTH_PROVIDER_ERROR = "5120",
|
2024-05-08 17:31:20 +00:00
|
|
|
// Reset Password
|
2024-05-20 06:53:48 +00:00
|
|
|
INVALID_PASSWORD_TOKEN = "5125",
|
|
|
|
EXPIRED_PASSWORD_TOKEN = "5130",
|
2024-05-08 17:31:20 +00:00
|
|
|
// Change password
|
2024-05-20 06:53:48 +00:00
|
|
|
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",
|
2024-05-08 17:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type TAuthErrorInfo = {
|
|
|
|
type: EErrorAlertType;
|
|
|
|
code: EAuthenticationErrorCodes;
|
|
|
|
title: string;
|
|
|
|
message: ReactNode;
|
|
|
|
};
|
|
|
|
|
|
|
|
const errorCodeMessages: {
|
|
|
|
[key in EAuthenticationErrorCodes]: { title: string; message: (email?: string | undefined) => ReactNode };
|
|
|
|
} = {
|
|
|
|
// global
|
|
|
|
[EAuthenticationErrorCodes.INSTANCE_NOT_CONFIGURED]: {
|
|
|
|
title: `Instance not configured`,
|
|
|
|
message: () => `Instance not configured. Please contact your administrator.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.SIGNUP_DISABLED]: {
|
|
|
|
title: `Sign up disabled`,
|
|
|
|
message: () => `Sign up disabled. Please contact your administrator.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.INVALID_PASSWORD]: {
|
|
|
|
title: `Invalid password`,
|
|
|
|
message: () => `Invalid password. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.SMTP_NOT_CONFIGURED]: {
|
|
|
|
title: `SMTP not configured`,
|
|
|
|
message: () => `SMTP not configured. Please contact your administrator.`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// email check in both sign up and sign in
|
|
|
|
[EAuthenticationErrorCodes.INVALID_EMAIL]: {
|
|
|
|
title: `Invalid email`,
|
|
|
|
message: () => `Invalid email. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.EMAIL_REQUIRED]: {
|
|
|
|
title: `Email required`,
|
|
|
|
message: () => `Email required. Please try again.`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// sign up
|
|
|
|
[EAuthenticationErrorCodes.USER_ALREADY_EXIST]: {
|
|
|
|
title: `User already exists`,
|
|
|
|
message: (email = undefined) => (
|
|
|
|
<div>
|
|
|
|
Your account is already registered.
|
|
|
|
<Link
|
|
|
|
className="underline underline-offset-4 font-medium hover:font-bold transition-all"
|
2024-05-20 06:53:48 +00:00
|
|
|
href={`/sign-in${email ? `?email=${encodeURIComponent(email)}` : ``}`}
|
2024-05-08 17:31:20 +00:00
|
|
|
>
|
|
|
|
Sign In
|
|
|
|
</Link>
|
|
|
|
now.
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_UP]: {
|
|
|
|
title: `Email and password required`,
|
|
|
|
message: () => `Email and password required. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_UP]: {
|
|
|
|
title: `Authentication failed`,
|
|
|
|
message: () => `Authentication failed. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_UP]: {
|
|
|
|
title: `Invalid email`,
|
|
|
|
message: () => `Invalid email. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.MAGIC_SIGN_UP_EMAIL_CODE_REQUIRED]: {
|
|
|
|
title: `Email and code required`,
|
|
|
|
message: () => `Email and code required. Please try again.`,
|
|
|
|
},
|
2024-05-20 06:53:48 +00:00
|
|
|
[EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_UP]: {
|
|
|
|
title: `Invalid email`,
|
|
|
|
message: () => `Invalid email. Please try again.`,
|
|
|
|
},
|
2024-05-08 17:31:20 +00:00
|
|
|
|
|
|
|
// sign in
|
2024-05-14 15:23:51 +00:00
|
|
|
[EAuthenticationErrorCodes.USER_ACCOUNT_DEACTIVATED]: {
|
|
|
|
title: `User account deactivated`,
|
2024-05-23 08:57:16 +00:00
|
|
|
message: () => `User account deactivated. Please contact ${!!SUPPORT_EMAIL ? SUPPORT_EMAIL : "administrator"}.`,
|
2024-05-14 15:23:51 +00:00
|
|
|
},
|
|
|
|
|
2024-05-08 17:31:20 +00:00
|
|
|
[EAuthenticationErrorCodes.USER_DOES_NOT_EXIST]: {
|
|
|
|
title: `User does not exist`,
|
|
|
|
message: (email = undefined) => (
|
|
|
|
<div>
|
|
|
|
No account found.
|
|
|
|
<Link
|
|
|
|
className="underline underline-offset-4 font-medium hover:font-bold transition-all"
|
2024-05-16 06:02:48 +00:00
|
|
|
href={`/${email ? `?email=${encodeURIComponent(email)}` : ``}`}
|
2024-05-08 17:31:20 +00:00
|
|
|
>
|
|
|
|
Create one
|
|
|
|
</Link>
|
|
|
|
to get started.
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_IN]: {
|
|
|
|
title: `Email and password required`,
|
|
|
|
message: () => `Email and password required. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_IN]: {
|
|
|
|
title: `Authentication failed`,
|
|
|
|
message: () => `Authentication failed. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_IN]: {
|
|
|
|
title: `Invalid email`,
|
|
|
|
message: () => `Invalid email. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.MAGIC_SIGN_IN_EMAIL_CODE_REQUIRED]: {
|
|
|
|
title: `Email and code required`,
|
|
|
|
message: () => `Email and code required. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_IN]: {
|
|
|
|
title: `Invalid email`,
|
|
|
|
message: () => `Invalid email. Please try again.`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Both Sign in and Sign up
|
2024-05-20 06:53:48 +00:00
|
|
|
[EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_IN]: {
|
|
|
|
title: `Authentication failed`,
|
|
|
|
message: () => `Invalid magic code. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.INVALID_MAGIC_CODE_SIGN_UP]: {
|
2024-05-08 17:31:20 +00:00
|
|
|
title: `Authentication failed`,
|
|
|
|
message: () => `Invalid magic code. Please try again.`,
|
|
|
|
},
|
2024-05-20 06:53:48 +00:00
|
|
|
[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]: {
|
2024-05-08 17:31:20 +00:00
|
|
|
title: `Expired magic code`,
|
|
|
|
message: () => `Expired magic code. Please try again.`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Oauth
|
|
|
|
[EAuthenticationErrorCodes.GOOGLE_NOT_CONFIGURED]: {
|
|
|
|
title: `Google not configured`,
|
|
|
|
message: () => `Google not configured. Please contact your administrator.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.GITHUB_NOT_CONFIGURED]: {
|
|
|
|
title: `GitHub not configured`,
|
|
|
|
message: () => `GitHub not configured. Please contact your administrator.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.GOOGLE_OAUTH_PROVIDER_ERROR]: {
|
|
|
|
title: `Google OAuth provider error`,
|
|
|
|
message: () => `Google OAuth provider error. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.GITHUB_OAUTH_PROVIDER_ERROR]: {
|
|
|
|
title: `GitHub OAuth provider error`,
|
|
|
|
message: () => `GitHub OAuth provider error. Please try again.`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Reset Password
|
|
|
|
[EAuthenticationErrorCodes.INVALID_PASSWORD_TOKEN]: {
|
|
|
|
title: `Invalid password token`,
|
|
|
|
message: () => `Invalid password token. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.EXPIRED_PASSWORD_TOKEN]: {
|
|
|
|
title: `Expired password token`,
|
|
|
|
message: () => `Expired password token. Please try again.`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Change password
|
2024-05-20 06:53:48 +00:00
|
|
|
[EAuthenticationErrorCodes.MISSING_PASSWORD]: {
|
|
|
|
title: `Password required`,
|
|
|
|
message: () => `Password required. Please try again.`,
|
|
|
|
},
|
2024-05-08 17:31:20 +00:00
|
|
|
[EAuthenticationErrorCodes.INCORRECT_OLD_PASSWORD]: {
|
|
|
|
title: `Incorrect old password`,
|
|
|
|
message: () => `Incorrect old password. Please try again.`,
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.INVALID_NEW_PASSWORD]: {
|
|
|
|
title: `Invalid new password`,
|
|
|
|
message: () => `Invalid new password. Please try again.`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// set password
|
|
|
|
[EAuthenticationErrorCodes.PASSWORD_ALREADY_SET]: {
|
|
|
|
title: `Password already set`,
|
|
|
|
message: () => `Password already set. Please try again.`,
|
|
|
|
},
|
2024-05-20 06:53:48 +00:00
|
|
|
|
|
|
|
// 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: () => (
|
|
|
|
<div>
|
|
|
|
Admin user already exists.
|
|
|
|
<Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>
|
|
|
|
Sign In
|
|
|
|
</Link>
|
|
|
|
now.
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
[EAuthenticationErrorCodes.ADMIN_USER_DOES_NOT_EXIST]: {
|
|
|
|
title: `Admin user does not exist`,
|
|
|
|
message: () => (
|
|
|
|
<div>
|
|
|
|
Admin user does not exist.
|
|
|
|
<Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>
|
|
|
|
Sign In
|
|
|
|
</Link>
|
|
|
|
now.
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
},
|
2024-05-08 17:31:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const authErrorHandler = (
|
|
|
|
errorCode: EAuthenticationErrorCodes,
|
|
|
|
email?: string | undefined
|
|
|
|
): TAuthErrorInfo | undefined => {
|
2024-05-20 06:53:48 +00:00
|
|
|
const bannerAlertErrorCodes = [
|
|
|
|
EAuthenticationErrorCodes.INSTANCE_NOT_CONFIGURED,
|
|
|
|
EAuthenticationErrorCodes.INVALID_EMAIL,
|
|
|
|
EAuthenticationErrorCodes.EMAIL_REQUIRED,
|
2024-05-08 17:31:20 +00:00
|
|
|
EAuthenticationErrorCodes.SIGNUP_DISABLED,
|
|
|
|
EAuthenticationErrorCodes.INVALID_PASSWORD,
|
|
|
|
EAuthenticationErrorCodes.SMTP_NOT_CONFIGURED,
|
2024-05-20 06:53:48 +00:00
|
|
|
EAuthenticationErrorCodes.USER_ALREADY_EXIST,
|
2024-05-08 17:31:20 +00:00
|
|
|
EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_UP,
|
2024-05-20 06:53:48 +00:00
|
|
|
EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_UP,
|
2024-05-08 17:31:20 +00:00
|
|
|
EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_UP,
|
2024-05-20 06:53:48 +00:00
|
|
|
EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_UP,
|
2024-05-08 17:31:20 +00:00
|
|
|
EAuthenticationErrorCodes.MAGIC_SIGN_UP_EMAIL_CODE_REQUIRED,
|
2024-05-20 06:53:48 +00:00
|
|
|
EAuthenticationErrorCodes.USER_DOES_NOT_EXIST,
|
2024-05-08 17:31:20 +00:00
|
|
|
EAuthenticationErrorCodes.AUTHENTICATION_FAILED_SIGN_IN,
|
2024-05-20 06:53:48 +00:00
|
|
|
EAuthenticationErrorCodes.REQUIRED_EMAIL_PASSWORD_SIGN_IN,
|
2024-05-08 17:31:20 +00:00
|
|
|
EAuthenticationErrorCodes.INVALID_EMAIL_SIGN_IN,
|
|
|
|
EAuthenticationErrorCodes.INVALID_EMAIL_MAGIC_SIGN_IN,
|
2024-05-20 06:53:48 +00:00
|
|
|
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,
|
2024-05-08 17:31:20 +00:00
|
|
|
EAuthenticationErrorCodes.GOOGLE_NOT_CONFIGURED,
|
|
|
|
EAuthenticationErrorCodes.GITHUB_NOT_CONFIGURED,
|
|
|
|
EAuthenticationErrorCodes.GOOGLE_OAUTH_PROVIDER_ERROR,
|
|
|
|
EAuthenticationErrorCodes.GITHUB_OAUTH_PROVIDER_ERROR,
|
|
|
|
EAuthenticationErrorCodes.INVALID_PASSWORD_TOKEN,
|
|
|
|
EAuthenticationErrorCodes.EXPIRED_PASSWORD_TOKEN,
|
|
|
|
EAuthenticationErrorCodes.INCORRECT_OLD_PASSWORD,
|
|
|
|
EAuthenticationErrorCodes.INVALID_NEW_PASSWORD,
|
|
|
|
EAuthenticationErrorCodes.PASSWORD_ALREADY_SET,
|
2024-05-20 06:53:48 +00:00
|
|
|
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,
|
2024-05-14 15:23:51 +00:00
|
|
|
EAuthenticationErrorCodes.USER_ACCOUNT_DEACTIVATED,
|
2024-05-08 17:31:20 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
if (bannerAlertErrorCodes.includes(errorCode))
|
|
|
|
return {
|
|
|
|
type: EErrorAlertType.BANNER_ALERT,
|
|
|
|
code: errorCode,
|
|
|
|
title: errorCodeMessages[errorCode]?.title || "Error",
|
|
|
|
message: errorCodeMessages[errorCode]?.message(email) || "Something went wrong. Please try again.",
|
|
|
|
};
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
};
|