aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/otp.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/otp.ts')
-rw-r--r--server/helpers/otp.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/helpers/otp.ts b/server/helpers/otp.ts
index a13edc5e2..a32cc9621 100644
--- a/server/helpers/otp.ts
+++ b/server/helpers/otp.ts
@@ -1,11 +1,15 @@
1import { Secret, TOTP } from 'otpauth' 1import { Secret, TOTP } from 'otpauth'
2import { CONFIG } from '@server/initializers/config'
2import { WEBSERVER } from '@server/initializers/constants' 3import { WEBSERVER } from '@server/initializers/constants'
4import { decrypt } from './peertube-crypto'
3 5
4function isOTPValid (options: { 6async function isOTPValid (options: {
5 secret: string 7 encryptedSecret: string
6 token: string 8 token: string
7}) { 9}) {
8 const { token, secret } = options 10 const { token, encryptedSecret } = options
11
12 const secret = await decrypt(encryptedSecret, CONFIG.SECRETS.PEERTUBE)
9 13
10 const totp = new TOTP({ 14 const totp = new TOTP({
11 ...baseOTPOptions(), 15 ...baseOTPOptions(),