29 lines
812 B
TypeScript
29 lines
812 B
TypeScript
import { apiGet, apiPost } from './client'
|
|
|
|
export interface AuthSession {
|
|
authentication_required: boolean
|
|
authenticated: boolean
|
|
username: string | null
|
|
expires_at: string | null
|
|
role: 'operator' | 'guest' | null
|
|
guest_access_enabled: boolean
|
|
authentik_enabled?: boolean
|
|
guest_project_id: string | null
|
|
}
|
|
|
|
export function getAuthSession(): Promise<AuthSession> {
|
|
return apiGet<AuthSession>('/api/v1/auth/session')
|
|
}
|
|
|
|
export function login(username: string, password: string): Promise<AuthSession> {
|
|
return apiPost<AuthSession>('/api/v1/auth/login', { username, password })
|
|
}
|
|
|
|
export function loginAsGuest(): Promise<AuthSession> {
|
|
return apiPost<AuthSession>('/api/v1/auth/guest')
|
|
}
|
|
|
|
export function logout(): Promise<AuthSession> {
|
|
return apiPost<AuthSession>('/api/v1/auth/logout')
|
|
}
|