]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/plugins/register-server-auth.model.ts
Begin auth plugin support
[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 type: 'id-and-pass'
7
8 onLogout?: Function
9
10 getWeight(): number
11
12 // Used by PeerTube to login a user
13 // Returns null if the login failed, or { username, email } on success
14 login(body: {
15 id: string
16 password: string
17 }): Promise<{
18 username: string
19 email: string
20 role?: UserRole
21 displayName?: string
22 } | null>
23 }
24
25 export interface RegisterServerAuthExternalOptions {
26 type: 'external'
27
28 onLogout?: Function
29 }
30
31 export interface RegisterServerAuthExternalResult {
32 onAuth (options: { username: string, email: string }): void
33 }