1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-10-01 00:50:10 +02:00

feat: change totp issuer to display logo in 2FAS app

This commit is contained in:
Elias Schneider 2023-11-03 08:38:23 +01:00 committed by GitHub
parent bbfc9d6f14
commit e0fbbeca3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,6 @@ import { User } from "@prisma/client";
import * as argon from "argon2"; import * as argon from "argon2";
import { authenticator, totp } from "otplib"; import { authenticator, totp } from "otplib";
import * as qrcode from "qrcode-svg"; import * as qrcode from "qrcode-svg";
import { ConfigService } from "src/config/config.service";
import { PrismaService } from "src/prisma/prisma.service"; import { PrismaService } from "src/prisma/prisma.service";
import { AuthService } from "./auth.service"; import { AuthService } from "./auth.service";
import { AuthSignInTotpDTO } from "./dto/authSignInTotp.dto"; import { AuthSignInTotpDTO } from "./dto/authSignInTotp.dto";
@ -18,7 +17,6 @@ export class AuthTotpService {
constructor( constructor(
private prisma: PrismaService, private prisma: PrismaService,
private authService: AuthService, private authService: AuthService,
private config: ConfigService,
) {} ) {}
async signInTotp(dto: AuthSignInTotpDTO) { async signInTotp(dto: AuthSignInTotpDTO) {
@ -78,12 +76,11 @@ export class AuthTotpService {
throw new BadRequestException("TOTP is already enabled"); throw new BadRequestException("TOTP is already enabled");
} }
// TODO: Maybe make the issuer configurable with env vars?
const secret = authenticator.generateSecret(); const secret = authenticator.generateSecret();
const otpURL = totp.keyuri( const otpURL = totp.keyuri(
user.username || user.email, user.username || user.email,
this.config.get("general.appName"), "pingvin-share",
secret, secret,
); );