]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/otp.ts
Fix pending subscription deletion
[github/Chocobozzz/PeerTube.git] / server / helpers / otp.ts
index a13edc5e2103a8c3f294fa30ee29da7d0bee5b25..a32cc96210b8cab68ca34216dc7cbf0e582a9a79 100644 (file)
@@ -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(),