Skip to content

Commit

Permalink
added apt. toast message
Browse files Browse the repository at this point in the history
  • Loading branch information
subhanahujha007 committed Oct 29, 2024
1 parent f638d1c commit 6eed718
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/auth/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ export const Signin = () => {
try {
const response = await signIn('signin', { ...data, redirect: false });
if (!response?.ok) {
const errorMessage =
response?.error?.includes('User') && response?.error?.includes('does not exist')
? 'User does not exist'
: response?.error || 'Internal server error';

return toast({
title: response?.error || 'Internal server error',
title: errorMessage,
variant: 'destructive',
});
}
toast({
title: 'Login successful! Welcome back!',
variant: 'success',
});
// const redirect = searchParams.get('next') || APP_PATHS.HOME;

const searchParams = new URLSearchParams(window.location.search);
const redirect = searchParams.get('next') || APP_PATHS.HOME;
router.push(redirect);
Expand All @@ -60,7 +65,7 @@ export const Signin = () => {
});
}
}

return (
<div className="">
<Form {...form}>
Expand Down

0 comments on commit 6eed718

Please sign in to comment.