]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
Translated using Weblate (French (France) (fr_FR))
[github/Chocobozzz/PeerTube.git] / server / tests / fixtures / peertube-plugin-test-id-pass-auth-two / main.js
CommitLineData
7fed6375
C
1async function register ({
2 registerIdAndPassAuth,
3 peertubeHelpers
4}) {
5 registerIdAndPassAuth({
e1c55031 6 authName: 'laguna-auth',
7fed6375
C
7
8 onLogout: () => {
9 peertubeHelpers.logger.info('On logout for auth 2 - 1')
10 },
11
12 getWeight: () => 30,
13
e307e4fc
C
14 hookTokenValidity: (options) => {
15 if (options.type === 'refresh') {
16 return { valid: false }
17 }
18
19 if (options.type === 'access') {
20 const token = options.token
21 const now = new Date()
22 now.setTime(now.getTime() - 5000)
23
24 const createdAt = new Date(token.createdAt)
25
26 return { valid: createdAt.getTime() >= now.getTime() }
27 }
28
29 return { valid: true }
30 },
31
7fed6375
C
32 login (body) {
33 if (body.id === 'laguna' && body.password === 'laguna password') {
34 return Promise.resolve({
35 username: 'laguna',
60b880ac
C
36 email: 'laguna@example.com',
37 displayName: 'Laguna Loire',
38 adminFlags: 1,
39 videoQuota: 42000,
40 videoQuotaDaily: 42100,
41
42 // Always use new value except for videoQuotaDaily field
43 userUpdater: ({ fieldName, currentValue, newValue }) => {
44 if (fieldName === 'videoQuotaDaily') return currentValue
45
46 return newValue
47 }
7fed6375
C
48 })
49 }
50
51 return null
52 }
53 })
54}
55
56async function unregister () {
57 return
58}
59
60module.exports = {
61 register,
62 unregister
63}
64
65// ###########################################################################