mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-03 17:44:44 +02:00
verify email workflow working
This commit is contained in:
parent
e176295593
commit
76eeb335a3
23 changed files with 16363 additions and 15802 deletions
|
@ -58,27 +58,36 @@ export async function verifyTotp(
|
|||
);
|
||||
}
|
||||
|
||||
const totpController = new TOTPController();
|
||||
const valid = await totpController.verify(
|
||||
code,
|
||||
decodeHex(user.twoFactorSecret),
|
||||
);
|
||||
try {
|
||||
const totpController = new TOTPController();
|
||||
const valid = await totpController.verify(
|
||||
code,
|
||||
decodeHex(user.twoFactorSecret),
|
||||
);
|
||||
|
||||
if (valid) {
|
||||
// if valid, enable two-factor authentication; the totp secret is no longer temporary
|
||||
await db
|
||||
.update(users)
|
||||
.set({ twoFactorEnabled: true })
|
||||
.where(eq(users.id, user.id));
|
||||
if (valid) {
|
||||
// if valid, enable two-factor authentication; the totp secret is no longer temporary
|
||||
await db
|
||||
.update(users)
|
||||
.set({ twoFactorEnabled: true })
|
||||
.where(eq(users.id, user.id));
|
||||
}
|
||||
|
||||
return response<{ valid: boolean }>(res, {
|
||||
data: { valid },
|
||||
success: true,
|
||||
error: false,
|
||||
message: valid
|
||||
? "Code is valid. Two-factor is now enabled"
|
||||
: "Code is invalid",
|
||||
status: HttpCode.OK,
|
||||
});
|
||||
} catch (error) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.INTERNAL_SERVER_ERROR,
|
||||
"Failed to verify two-factor authentication code",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return response<{ valid: boolean }>(res, {
|
||||
data: { valid },
|
||||
success: true,
|
||||
error: false,
|
||||
message: valid
|
||||
? "Code is valid. Two-factor is now enabled"
|
||||
: "Code is invalid",
|
||||
status: HttpCode.OK,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue