]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/plugins/register-server-auth.model.ts
Support logout and add id and pass tests
[github/Chocobozzz/PeerTube.git] / shared / models / plugins / register-server-auth.model.ts
1 import { UserRole } from '@shared/models'
2
3 export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions
4
5 export interface RegisterServerAuthPassOptions {
6 // Authentication name (a plugin can register multiple auth strategies)
7 authName: string
8
9 onLogout?: Function
10
11 // Weight of this authentication so PeerTube tries the auth methods in DESC weight order
12 getWeight(): number
13
14 // Used by PeerTube to login a user
15 // Returns null if the login failed, or { username, email } on success
16 login(body: {
17 id: string
18 password: string
19 }): Promise<{
20 username: string
21 email: string
22 role?: UserRole
23 displayName?: string
24 } | null>
25 }
26
27 export interface RegisterServerAuthExternalOptions {
28 // Authentication name (a plugin can register multiple auth strategies)
29 authName: string
30
31 onLogout?: Function
32 }
33
34 export interface RegisterServerAuthExternalResult {
35 onAuth (options: { username: string, email: string }): void
36 }