From 6953cdf1590e25684dda4de7c95b99eb5c61fc00 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 11 May 2019 00:20:02 -0600 Subject: [PATCH] QR's can't alwasy be created --- core/user_2fa_otp.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/user_2fa_otp.js b/core/user_2fa_otp.js index 83524750..2f51f105 100644 --- a/core/user_2fa_otp.js +++ b/core/user_2fa_otp.js @@ -107,18 +107,22 @@ function validateAndConsumeBackupCode(user, token, cb) { } function createQRCode(otp, options, secret) { - const uri = otp.keyuri(options.username || 'user', Config().general.boardName, secret); - const qrCode = qrGen(0, 'L'); - qrCode.addData(uri); - qrCode.make(); + try { + const uri = otp.keyuri(options.username || 'user', Config().general.boardName, secret); + const qrCode = qrGen(0, 'L'); + qrCode.addData(uri); + qrCode.make(); - options.qrType = options.qrType || 'ascii'; - return { - ascii : qrCode.createASCII, - data : qrCode.createDataURL, - img : qrCode.createImgTag, - svg : qrCode.createSvgTag, - }[options.qrType](); + options.qrType = options.qrType || 'ascii'; + return { + ascii : qrCode.createASCII, + data : qrCode.createDataURL, + img : qrCode.createImgTag, + svg : qrCode.createSvgTag, + }[options.qrType](); + } catch(e) { + return; + } } function prepareOTP(otpType, options, cb) {