Skip to content

Commit 3ffc50f

Browse files
Merge pull request #19 from Amsterdam/feature/create-own-qr-code
Create own qrCode
2 parents d36722f + 1378a2e commit 3ffc50f

File tree

3 files changed

+300
-16
lines changed

3 files changed

+300
-16
lines changed

controllers/auth/twoFactor.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const twofactor = require("node-2fa");
2+
const QRCode = require('qrcode')
23

34
const twoFactorBaseUrl = `${process.env.APP_URL}/auth/two-factor`;
45

@@ -109,7 +110,8 @@ exports.configure = async (req, res, next) => {
109110

110111
}
111112

112-
const qrCode = `https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=otpauth://totp/=${encodeURIComponent(issuer)}:${encodeURIComponent(accountName)}%3Fsecret=${twoFactorSecret}%26issuer=${encodeURIComponent(issuer)}`;
113+
const otpAuthUrl = `otpauth://totp/${encodeURIComponent(issuer)}:%20${encodeURIComponent(accountName)}?secret=${twoFactorSecret}&issuer=${encodeURIComponent(issuer)}`;
114+
const qrCode = await QRCode.toDataURL(otpAuthUrl)
113115

114116
res.render('auth/two-factor/configure', {
115117
postUrl: twoFactorBaseUrl + '/configure',

0 commit comments

Comments
 (0)