mirror of
https://github.com/fosrl/pangolin.git
synced 2025-09-01 07:20:06 +02:00
added change password endpoint
This commit is contained in:
parent
84cd743d0c
commit
dca6924a5c
9 changed files with 207 additions and 71 deletions
15
server/routers/auth/verifyTotpCode.ts
Normal file
15
server/routers/auth/verifyTotpCode.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { decodeHex } from "oslo/encoding";
|
||||
import { TOTPController } from "oslo/otp";
|
||||
|
||||
export async function verifyTotpCode(
|
||||
code: string,
|
||||
secret: string,
|
||||
): Promise<boolean> {
|
||||
const validOTP = await new TOTPController().verify(code, decodeHex(secret));
|
||||
|
||||
if (!validOTP) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 250)); // delay to prevent brute force attack
|
||||
}
|
||||
|
||||
return validOTP;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue