26 lines
589 B
TypeScript
26 lines
589 B
TypeScript
import api from '../utils/api';
|
|
|
|
export interface LoginRequest {
|
|
username: string;
|
|
password: string;
|
|
}
|
|
|
|
export interface LoginResponse {
|
|
accessToken: string;
|
|
userId: number;
|
|
username: string;
|
|
role: string;
|
|
}
|
|
|
|
export const adminAuthService = {
|
|
async login(data: LoginRequest): Promise<LoginResponse> {
|
|
const response = await api.post<LoginResponse>('/admin/auth/login', data);
|
|
return response.data;
|
|
},
|
|
|
|
async logout(): Promise<{ message: string }> {
|
|
const response = await api.post<{ message: string }>('/admin/auth/logout');
|
|
return response.data;
|
|
},
|
|
};
|