mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 20:55:30 +02:00
Work on 2FA/OTP email system
* Web routes/handler/etc. mostly functional * Can now enable -> follow link -> submit -> capture form * Clean up code
This commit is contained in:
parent
fa3e3e5802
commit
3efea3de9a
8 changed files with 273 additions and 85 deletions
|
@ -25,17 +25,17 @@ exports.WellKnownTokenTypes = {
|
|||
AuthFactor2OTPRegister : 'auth_factor2_otp_register',
|
||||
};
|
||||
|
||||
function createToken(userId, tokenType, cb) {
|
||||
function createToken(userId, tokenType, options = { bits : 128 }, cb) {
|
||||
async.waterfall(
|
||||
[
|
||||
(callback) => {
|
||||
return crypto.randomBytes(256, callback);
|
||||
return crypto.randomBytes(options.bits, callback);
|
||||
},
|
||||
(token, callback) => {
|
||||
token = token.toString('hex');
|
||||
|
||||
UserDb.run(
|
||||
`INSERT INTO user_temporary_token (user_id, token, token_type, timestamp)
|
||||
`INSERT OR REPLACE INTO user_temporary_token (user_id, token, token_type, timestamp)
|
||||
VALUES (?, ?, ?, ?);`,
|
||||
[ userId, token, tokenType, getISOTimestampString() ],
|
||||
err => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue