QR's can't alwasy be created

This commit is contained in:
Bryan Ashby 2019-05-11 00:20:02 -06:00
parent 401d0a10b1
commit 6953cdf159
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
1 changed files with 15 additions and 11 deletions

View File

@ -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) {