Move redirect to outside try..catch block
This commit is contained in:
parent
24eefcc253
commit
c27305dc0f
|
|
@ -87,9 +87,11 @@ export default async function createUser(formData: FormData){
|
|||
|
||||
const token = createJwtToken({ id: user.id });
|
||||
cookies().set("token", token);
|
||||
redirect("/dashboard");
|
||||
} catch (e: unknown) {
|
||||
// Handle unexpected errors
|
||||
console.error(e)
|
||||
//@ts-ignore
|
||||
console.log(e.message)
|
||||
return {
|
||||
success: false,
|
||||
error: {
|
||||
|
|
@ -97,4 +99,6 @@ export default async function createUser(formData: FormData){
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
redirect("/dashboard");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@ export default async function signIn(prevState: any, rawFormData: FormData) {
|
|||
const token = createJwtToken({ id: user.id });
|
||||
|
||||
cookies().set("token", token);
|
||||
|
||||
redirect("/dashboard");
|
||||
} catch (e: unknown) {
|
||||
// Custom error handling for authentication errors
|
||||
if (e instanceof BaseError) {
|
||||
|
|
@ -87,4 +85,6 @@ export default async function signIn(prevState: any, rawFormData: FormData) {
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
redirect("/dashboard");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user