feat: login + TFA authentication
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
'use strict'
|
||||
|
||||
/* global appdata, appconfig */
|
||||
|
||||
const _ = require('lodash')
|
||||
const Promise = require('bluebird')
|
||||
const crypto = require('crypto')
|
||||
|
||||
module.exports = {
|
||||
sanitizeCommitUser (user) {
|
||||
let wlist = new RegExp('[^a-zA-Z0-9-_.\',& ' + appdata.regex.cjk + appdata.regex.arabic + ']', 'g')
|
||||
return {
|
||||
name: _.chain(user.name).replace(wlist, '').trim().value(),
|
||||
email: appconfig.git.showUserEmail ? user.email : appconfig.git.serverEmail
|
||||
}
|
||||
// let wlist = new RegExp('[^a-zA-Z0-9-_.\',& ' + appdata.regex.cjk + appdata.regex.arabic + ']', 'g')
|
||||
// return {
|
||||
// name: _.chain(user.name).replace(wlist, '').trim().value(),
|
||||
// email: appconfig.git.showUserEmail ? user.email : appconfig.git.serverEmail
|
||||
// }
|
||||
},
|
||||
/**
|
||||
* Generate a random token
|
||||
*
|
||||
* @param {any} length
|
||||
* @returns
|
||||
*/
|
||||
async generateToken (length) {
|
||||
return Promise.fromCallback(clb => {
|
||||
crypto.randomBytes(length, clb)
|
||||
}).then(buf => {
|
||||
return buf.toString('hex')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user