You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
674 B

  1. const Promise = require('bluebird')
  2. const crypto = require('crypto')
  3. module.exports = {
  4. sanitizeCommitUser (user) {
  5. // let wlist = new RegExp('[^a-zA-Z0-9-_.\',& ' + appdata.regex.cjk + appdata.regex.arabic + ']', 'g')
  6. // return {
  7. // name: _.chain(user.name).replace(wlist, '').trim().value(),
  8. // email: appconfig.git.showUserEmail ? user.email : appconfig.git.serverEmail
  9. // }
  10. },
  11. /**
  12. * Generate a random token
  13. *
  14. * @param {any} length
  15. * @returns
  16. */
  17. async generateToken (length) {
  18. return Promise.fromCallback(clb => {
  19. crypto.randomBytes(length, clb)
  20. }).then(buf => {
  21. return buf.toString('hex')
  22. })
  23. }
  24. }