fix(mfa): generate SVG QR code
Replace the rasterized 180px PNG QR code with a crisp 250px SVG
This commit is contained in:
@@ -260,8 +260,8 @@ router.post('/mfa/setup', authenticate, (req: Request, res: Response) => {
|
||||
const result = setupMfa(authReq.user.id, authReq.user.email);
|
||||
if (result.error) return res.status(result.status!).json({ error: result.error });
|
||||
result.qrPromise!
|
||||
.then((qr_data_url: string) => {
|
||||
res.json({ secret: result.secret, otpauth_url: result.otpauth_url, qr_data_url });
|
||||
.then((qr_svg: string) => {
|
||||
res.json({ secret: result.secret, otpauth_url: result.otpauth_url, qr_svg });
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
console.error('[MFA] QR code generation error:', err);
|
||||
|
||||
@@ -816,7 +816,7 @@ export function setupMfa(userId: number, userEmail: string): { error?: string; s
|
||||
console.error('[MFA] Setup error:', err);
|
||||
return { error: 'MFA setup failed', status: 500 };
|
||||
}
|
||||
return { secret, otpauth_url, qrPromise: QRCode.toDataURL(otpauth_url) };
|
||||
return { secret, otpauth_url, qrPromise: QRCode.toString(otpauth_url, { type: 'svg', width: 250 }) };
|
||||
}
|
||||
|
||||
export function enableMfa(userId: number, code?: string): { error?: string; status?: number; success?: boolean; mfa_enabled?: boolean; backup_codes?: string[] } {
|
||||
|
||||
Reference in New Issue
Block a user