diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-22 16:07:04 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-04 16:21:39 +0200 |
commit | 7fed637506043e4432cbebe041ada0625171cceb (patch) | |
tree | 07f174e17c4b4a0b3d43a0fa6944865c06234338 /server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js | |
parent | 8d4197637868d5cde49434e937186b57e40f4b2b (diff) | |
download | PeerTube-7fed637506043e4432cbebe041ada0625171cceb.tar.gz PeerTube-7fed637506043e4432cbebe041ada0625171cceb.tar.zst PeerTube-7fed637506043e4432cbebe041ada0625171cceb.zip |
Begin auth plugin support
Diffstat (limited to 'server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js b/server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js new file mode 100644 index 000000000..4755ed643 --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js | |||
@@ -0,0 +1,61 @@ | |||
1 | async function register ({ | ||
2 | registerIdAndPassAuth, | ||
3 | peertubeHelpers | ||
4 | }) { | ||
5 | registerIdAndPassAuth({ | ||
6 | type: 'id-and-pass', | ||
7 | |||
8 | onLogout: () => { | ||
9 | peertubeHelpers.logger.info('On logout for auth 1 - 1') | ||
10 | }, | ||
11 | |||
12 | getWeight: () => 15, | ||
13 | |||
14 | login (body) { | ||
15 | if (body.id === 'spyro' && body.password === 'spyro password') { | ||
16 | return Promise.resolve({ | ||
17 | username: 'spyro', | ||
18 | email: 'spyro@example.com', | ||
19 | role: 0, | ||
20 | displayName: 'Spyro the Dragon' | ||
21 | }) | ||
22 | } | ||
23 | |||
24 | return null | ||
25 | } | ||
26 | }) | ||
27 | |||
28 | registerIdAndPassAuth({ | ||
29 | type: 'id-and-pass', | ||
30 | |||
31 | onLogout: () => { | ||
32 | peertubeHelpers.logger.info('On logout for auth 1 - 2') | ||
33 | }, | ||
34 | |||
35 | getWeight: () => 50, | ||
36 | |||
37 | login (body) { | ||
38 | if (body.id === 'crash' && body.password === 'crash password') { | ||
39 | return Promise.resolve({ | ||
40 | username: 'crash', | ||
41 | email: 'crash@example.com', | ||
42 | role: 2, | ||
43 | displayName: 'Crash Bandicoot' | ||
44 | }) | ||
45 | } | ||
46 | |||
47 | return null | ||
48 | } | ||
49 | }) | ||
50 | } | ||
51 | |||
52 | async function unregister () { | ||
53 | return | ||
54 | } | ||
55 | |||
56 | module.exports = { | ||
57 | register, | ||
58 | unregister | ||
59 | } | ||
60 | |||
61 | // ########################################################################### | ||