<commit_before>const speakeasy = require("speakeasy");
const QRCode = require("QRCode");

exports.getTOTPSetup = function(req, res, next) {
    if(req.user.twoFactorAuthEnabled()) return res.status(403).json({success: false, error: {message: "You already have two-factor authentication set up on your account.", code: "totp_already_setup"}});
    var secret = speakeasy.generateSecret({length: 20, issuer: "Place 2.0", name: req.user.name});
    var url = speakeasy.otpauthURL({secret: secret.ascii, label: req.user.name, issuer: "Place 2.0"});
    QRCode.toDataURL(url, function(err, data_url) {
        if(err) return res.status(500).json({success: false, error: {message: "An error occurred while trying to set up two-factor authentication on your account."}})
        res.json({success: true, totp: {secret: secret.base32, qrData: data_url, authURL: url}});
      });
}<commit_msg>Fix QRCode import<commit_after>const speakeasy = require("speakeasy");
const QRCode = require("qrcode");

exports.getTOTPSetup = function(req, res, next) {
    if(req.user.twoFactorAuthEnabled()) return res.status(403).json({success: false, error: {message: "You already have two-factor authentication set up on your account.", code: "totp_already_setup"}});
    var secret = speakeasy.generateSecret({length: 20, issuer: "Place 2.0", name: req.user.name});
    var url = speakeasy.otpauthURL({secret: secret.ascii, label: req.user.name, issuer: "Place 2.0"});
    QRCode.toDataURL(url, function(err, data_url) {
        if(err) return res.status(500).json({success: false, error: {message: "An error occurred while trying to set up two-factor authentication on your account."}})
        res.json({success: true, totp: {secret: secret.base32, qrData: data_url, authURL: url}});
      });
}
{'fraction_non_alphanumeric': 0.15107102593010147, 'fraction_numerical': 0.015783540022547914, 'mean_word_length': 4.976430976430977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3291394', 'n_tokens_mistral': 589, 'n_tokens_neox': 558, 'n_words': 156}