]>
Commit | Line | Data |
---|---|---|
1 | async function register ({ | |
2 | registerIdAndPassAuth, | |
3 | peertubeHelpers, | |
4 | settingsManager, | |
5 | unregisterIdAndPassAuth | |
6 | }) { | |
7 | registerIdAndPassAuth({ | |
8 | authName: 'spyro-auth', | |
9 | ||
10 | onLogout: () => { | |
11 | peertubeHelpers.logger.info('On logout for auth 1 - 1') | |
12 | }, | |
13 | ||
14 | getWeight: () => 15, | |
15 | ||
16 | login (body) { | |
17 | if (body.id === 'spyro' && body.password === 'spyro password') { | |
18 | return Promise.resolve({ | |
19 | username: 'spyro', | |
20 | email: 'spyro@example.com', | |
21 | role: 2, | |
22 | displayName: 'Spyro the Dragon' | |
23 | }) | |
24 | } | |
25 | ||
26 | return null | |
27 | } | |
28 | }) | |
29 | ||
30 | registerIdAndPassAuth({ | |
31 | authName: 'crash-auth', | |
32 | ||
33 | onLogout: () => { | |
34 | peertubeHelpers.logger.info('On logout for auth 1 - 2') | |
35 | }, | |
36 | ||
37 | getWeight: () => 50, | |
38 | ||
39 | login (body) { | |
40 | if (body.id === 'crash' && body.password === 'crash password') { | |
41 | return Promise.resolve({ | |
42 | username: 'crash', | |
43 | email: 'crash@example.com', | |
44 | role: 1, | |
45 | displayName: 'Crash Bandicoot' | |
46 | }) | |
47 | } | |
48 | ||
49 | return null | |
50 | } | |
51 | }) | |
52 | ||
53 | settingsManager.onSettingsChange(settings => { | |
54 | if (settings.disableSpyro) { | |
55 | unregisterIdAndPassAuth('spyro-auth') | |
56 | } | |
57 | }) | |
58 | } | |
59 | ||
60 | async function unregister () { | |
61 | return | |
62 | } | |
63 | ||
64 | module.exports = { | |
65 | register, | |
66 | unregister | |
67 | } | |
68 | ||
69 | // ########################################################################### |