35 lines
815 B
TypeScript
35 lines
815 B
TypeScript
import request from './request';
|
|
|
|
export interface LoginResponse {
|
|
access_token: string;
|
|
token_type: string;
|
|
user: {
|
|
id: number;
|
|
username: string;
|
|
display_name: string;
|
|
role: string;
|
|
email: string | null;
|
|
data_source_permissions?: string;
|
|
custom_permissions?: string;
|
|
group_ids?: number[];
|
|
};
|
|
}
|
|
|
|
export interface MeResponse {
|
|
id: number;
|
|
username: string;
|
|
display_name: string;
|
|
role: string;
|
|
email: string | null;
|
|
data_source_permissions?: string;
|
|
custom_permissions?: string;
|
|
group_ids?: number[];
|
|
}
|
|
|
|
export const authApi = {
|
|
login: (username: string, password: string) =>
|
|
request.post<any, LoginResponse>('/auth/login', { username, password }),
|
|
getMe: () => request.get<any, MeResponse>('/auth/me'),
|
|
logout: () => request.post('/auth/logout'),
|
|
};
|