diff options
Diffstat (limited to 'server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js b/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js new file mode 100644 index 000000000..ceab7b60d --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js | |||
@@ -0,0 +1,54 @@ | |||
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 | // ########################################################################### | ||