X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fotp.ts;h=a32cc96210b8cab68ca34216dc7cbf0e582a9a79;hb=d3fcf1c57ab898e18654910e880875a911fbd128;hp=a13edc5e2103a8c3f294fa30ee29da7d0bee5b25;hpb=56f47830758ff8e92abcfcc5f35d474ab12fe215;p=github%2FChocobozzz%2FPeerTube.git 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 @@ import { Secret, TOTP } from 'otpauth' +import { CONFIG } from '@server/initializers/config' import { WEBSERVER } from '@server/initializers/constants' +import { decrypt } from './peertube-crypto' -function isOTPValid (options: { - secret: string +async function isOTPValid (options: { + encryptedSecret: string token: string }) { - const { token, secret } = options + const { token, encryptedSecret } = options + + const secret = await decrypt(encryptedSecret, CONFIG.SECRETS.PEERTUBE) const totp = new TOTP({ ...baseOTPOptions(),