]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
Merge branch 'master' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / fixtures / peertube-plugin-test-id-pass-auth-two / main.js
1 async function register ({
2 registerIdAndPassAuth,
3 peertubeHelpers
4 }) {
5 registerIdAndPassAuth({
6 authName: 'laguna-auth',
7
8 onLogout: () => {
9 peertubeHelpers.logger.info('On logout for auth 2 - 1')
10 },
11
12 getWeight: () => 30,
13
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
32 login (body) {
33 if (body.id === 'laguna' && body.password === 'laguna password') {
34 return Promise.resolve({
35 username: 'laguna',
36 email: 'laguna@example.com'
37 })
38 }
39
40 return null
41 }
42 })
43 }
44
45 async function unregister () {
46 return
47 }
48
49 module.exports = {
50 register,
51 unregister
52 }
53
54 // ###########################################################################