Skip to content

Commit

Permalink
add proper messages
Browse files Browse the repository at this point in the history
  • Loading branch information
RajuGangitla committed Oct 14, 2024
1 parent cd68197 commit ce7ab5b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions apps/web/app/app.dub.co/(auth)/login/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const errorCodes = {
"Account has been locked due to too many login attempts. Please contact support to unlock your account.",
"too-many-login-attempts": "Too many login attempts. Please try again later.",
"email-not-verified": "Please verify your email address.",
"Callback": "We encountered an issue processing your request. Please try again or contact support if the problem persists.",
"OAuthSignin": "There was an issue signing you in. Please ensure your provider settings are correct.",
"OAuthCallback": "We faced a problem while processing the response from the OAuth provider. Please try again.",
};

const LoginFormContext = createContext<{
Expand All @@ -58,13 +61,13 @@ const LoginFormContext = createContext<{
setShowSSOOption: Dispatch<SetStateAction<boolean>>;
}>({
authMethod: undefined,
setAuthMethod: () => {},
setAuthMethod: () => { },
clickedMethod: undefined,
showPasswordField: false,
setShowPasswordField: () => {},
setClickedMethod: () => {},
setLastUsedAuthMethod: () => {},
setShowSSOOption: () => {},
setShowPasswordField: () => { },
setClickedMethod: () => { },
setLastUsedAuthMethod: () => { },
setShowSSOOption: () => { },
});

export default function LoginForm() {
Expand All @@ -89,7 +92,11 @@ export default function LoginForm() {

useEffect(() => {
const error = searchParams?.get("error");
error && toast.error(error);
if (error && errorCodes[error]) {
toast.error(errorCodes[error]);
} else {
toast.error("An unexpected error occurred. Please try again later.");
}
}, [searchParams]);

const { isMobile } = useMediaQuery();
Expand Down

0 comments on commit ce7ab5b

Please sign in to comment.