Federated video streaming platform using ActivityPub and P2P in the web browser with Angular. https://joinpeertube.org/
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

59 行
1.4 KiB

  1. import { program } from 'commander'
  2. import { isUserPasswordValid } from '../server/helpers/custom-validators/users'
  3. import { initDatabaseModels } from '../server/initializers/database'
  4. import { UserModel } from '../server/models/user/user'
  5. program
  6. .option('-u, --user [user]', 'User')
  7. .parse(process.argv)
  8. const options = program.opts()
  9. if (options.user === undefined) {
  10. console.error('All parameters are mandatory.')
  11. process.exit(-1)
  12. }
  13. initDatabaseModels(true)
  14. .then(() => {
  15. return UserModel.loadByUsername(options.user)
  16. })
  17. .then(user => {
  18. if (!user) {
  19. console.error('Unknown user.')
  20. process.exit(-1)
  21. }
  22. const readline = require('readline')
  23. const Writable = require('stream').Writable
  24. const mutableStdout = new Writable({
  25. write: function (_chunk, _encoding, callback) {
  26. callback()
  27. }
  28. })
  29. const rl = readline.createInterface({
  30. input: process.stdin,
  31. output: mutableStdout,
  32. terminal: true
  33. })
  34. console.log('New password?')
  35. rl.on('line', function (password) {
  36. if (!isUserPasswordValid(password)) {
  37. console.error('New password is invalid.')
  38. process.exit(-1)
  39. }
  40. user.password = password
  41. user.save()
  42. .then(() => console.log('User password updated.'))
  43. .catch(err => console.error(err))
  44. .finally(() => process.exit(0))
  45. })
  46. })
  47. .catch(err => {
  48. console.error(err)
  49. process.exit(-1)
  50. })