From c89ca7e64b08f437dd1b7e9bf2b9d674cc612228 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Thu, 24 Oct 2024 13:59:54 +0200 Subject: [PATCH] fix: use app name as totp issuer --- backend/src/auth/authTotp.service.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/src/auth/authTotp.service.ts b/backend/src/auth/authTotp.service.ts index ebbffe80..faa67c62 100644 --- a/backend/src/auth/authTotp.service.ts +++ b/backend/src/auth/authTotp.service.ts @@ -8,6 +8,7 @@ import { User } from "@prisma/client"; import * as argon from "argon2"; import { authenticator, totp } from "otplib"; import * as qrcode from "qrcode-svg"; +import { ConfigService } from "src/config/config.service"; import { PrismaService } from "src/prisma/prisma.service"; import { AuthService } from "./auth.service"; import { AuthSignInTotpDTO } from "./dto/authSignInTotp.dto"; @@ -16,6 +17,7 @@ import { AuthSignInTotpDTO } from "./dto/authSignInTotp.dto"; export class AuthTotpService { constructor( private prisma: PrismaService, + private configService: ConfigService, private authService: AuthService, ) {} @@ -76,13 +78,10 @@ export class AuthTotpService { throw new BadRequestException("TOTP is already enabled"); } + const issuer = this.configService.get("general.appName"); const secret = authenticator.generateSecret(); - const otpURL = totp.keyuri( - user.username || user.email, - "pingvin-share", - secret, - ); + const otpURL = totp.keyuri(user.username || user.email, issuer, secret); await this.prisma.user.update({ where: { id: user.id },