aboutsummaryrefslogblamecommitdiffhomepage
path: root/shared/models/plugins/register-server-auth.model.ts
blob: 34ebbe71223e45bc98e5e86b98158c4f93bd90ce (plain) (tree)
































                                                                                                         
import { UserRole } from '@shared/models'

export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions

export interface RegisterServerAuthPassOptions {
  type: 'id-and-pass'

  onLogout?: Function

  getWeight(): number

  // Used by PeerTube to login a user
  // Returns null if the login failed, or { username, email } on success
  login(body: {
    id: string
    password: string
  }): Promise<{
    username: string
    email: string
    role?: UserRole
    displayName?: string
  } | null>
}

export interface RegisterServerAuthExternalOptions {
  type: 'external'

  onLogout?: Function
}

export interface RegisterServerAuthExternalResult {
  onAuth (options: { username: string, email: string }): void
}