Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const passport = require('passport');
const validator = require('validator');
const mailChecker = require('mailchecker');
const OTPAuth = require('otpauth');
const encodeQR = require('qr').default;
const User = require('../models/User');
const Session = require('../models/Session');
const nodemailerConfig = require('../config/nodemailer');
Expand Down Expand Up @@ -970,9 +971,12 @@ exports.getTotpSetup = async (req, res, next) => {
secret,
});
req.session.totpSecret = secret.base32;
// Generate QR image (SVG) data URI using the `qr` package
const svg = encodeQR(totp.toString(), 'svg');
const qrImage = `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
Comment thread
YasharF marked this conversation as resolved.
res.render('account/totp-setup', {
title: 'Setup Authenticator',
qrCode: totp.toString(),
qrImage,
secret: secret.base32,
});
} catch (err) {
Expand Down
Loading
Loading