ニジカ投稿局 https://tv.nizika.tv
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.

main.js 1.4 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. async function register ({
  2. registerIdAndPassAuth,
  3. peertubeHelpers
  4. }) {
  5. registerIdAndPassAuth({
  6. authName: 'laguna-auth',
  7. onLogout: () => {
  8. peertubeHelpers.logger.info('On logout for auth 2 - 1')
  9. },
  10. getWeight: () => 30,
  11. hookTokenValidity: (options) => {
  12. if (options.type === 'refresh') {
  13. return { valid: false }
  14. }
  15. if (options.type === 'access') {
  16. const token = options.token
  17. const now = new Date()
  18. now.setTime(now.getTime() - 5000)
  19. const createdAt = new Date(token.createdAt)
  20. return { valid: createdAt.getTime() >= now.getTime() }
  21. }
  22. return { valid: true }
  23. },
  24. login (body) {
  25. if (body.id === 'laguna' && body.password === 'laguna password') {
  26. return Promise.resolve({
  27. username: 'laguna',
  28. email: 'laguna@example.com',
  29. displayName: 'Laguna Loire',
  30. adminFlags: 1,
  31. videoQuota: 42000,
  32. videoQuotaDaily: 42100,
  33. // Always use new value except for videoQuotaDaily field
  34. userUpdater: ({ fieldName, currentValue, newValue }) => {
  35. if (fieldName === 'videoQuotaDaily') return currentValue
  36. return newValue
  37. }
  38. })
  39. }
  40. return null
  41. }
  42. })
  43. }
  44. async function unregister () {
  45. return
  46. }
  47. module.exports = {
  48. register,
  49. unregister
  50. }
  51. // ###########################################################################