fix mail confirm work
This commit is contained in:
+15
-10
@@ -409,14 +409,8 @@ export async function tokenLifeExtension() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function confirmEmail(
|
||||
state: { error: string } | undefined,
|
||||
formData: FormData
|
||||
) {
|
||||
export async function confirmEmail(userId: number, verifyToken: string) {
|
||||
console.log('confirmEmail');
|
||||
const emailConfirm = formData.get('emailConfirm') as string || '';
|
||||
console.log(emailConfirm);
|
||||
const userId = formData.get('userId') as string || '';
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
@@ -431,7 +425,7 @@ export async function confirmEmail(
|
||||
message_body: {
|
||||
resend: 0,
|
||||
user_id: userId,
|
||||
verify_token: emailConfirm
|
||||
verify_token: verifyToken
|
||||
}
|
||||
}),
|
||||
});
|
||||
@@ -442,12 +436,23 @@ export async function confirmEmail(
|
||||
|
||||
if (parsed.message_code === 0) {
|
||||
await createSession(parsed.message_body.token, parsed.message_body.email as string);
|
||||
} else {
|
||||
return {
|
||||
success: false,
|
||||
error: 'entered-code-is-incorrect'
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
success: false,
|
||||
error: 'server-error'
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
error: 'error'
|
||||
}
|
||||
success: false,
|
||||
error: 'network-error'
|
||||
};
|
||||
}
|
||||
|
||||
redirect('/pages/dashboard');
|
||||
|
||||
Reference in New Issue
Block a user