Last active
January 9, 2022 19:08
-
-
Save PatrickKalkman/dbc97521b56f4fe36356e1dc040b6a8b to your computer and use it in GitHub Desktop.
Enabling two factor authentication step 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
userController.enableTwoFactorAuthStep1 = function (req, reply) { | |
tokenVerification.extractAndVerifyToken(req, (err, isValidToken, email) => { | |
if (!err && isValidToken) { | |
const secret = speakeasy.generateSecret(); | |
qrcode.toDataURL(secret.otpauth_url, function (err, qrImage) { | |
if (!err) { | |
reply.code(200).send({ qr: qrImage, secret: secret }); | |
} else { | |
reply.internalServerError(err); | |
} | |
}); | |
} else { | |
reply.unauthorized(err); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment