Download apps/web-naive/src/api/core/auth.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-naive/src/api/core/auth.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/apps/web-naive/src/api/core/auth.ts
-
curl -L -o auth.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-naive/src/api/core/auth.ts
1.15 kB
| import { baseRequestClient, requestClient } from '#/api/request'; | |
| export namespace AuthApi { | |
| /** 登录接口参数 */ | |
| export interface LoginParams { | |
| password?: string; | |
| username?: string; | |
| } | |
| /** 登录接口返回值 */ | |
| export interface LoginResult { | |
| accessToken: string; | |
| expires_in: number; | |
| } | |
| export interface RefreshTokenResult { | |
| data: string; | |
| status: number; | |
| } | |
| } | |
| /** | |
| * 登录 POST /admin/auth/login | |
| */ | |
| export async function loginApi(data: AuthApi.LoginParams) { | |
| return requestClient.post<AuthApi.LoginResult>('/admin/auth/login', data); | |
| } | |
| /** | |
| * 刷新 accessToken(后端暂不支持,保留接口签名供框架调用) | |
| */ | |
| export async function refreshTokenApi() { | |
| return baseRequestClient.post<AuthApi.RefreshTokenResult>( | |
| '/admin/auth/refresh', | |
| { withCredentials: true }, | |
| ); | |
| } | |
| /** | |
| * 退出登录 POST /admin/auth/logout | |
| */ | |
| export async function logoutApi() { | |
| return requestClient.post('/admin/auth/logout'); | |
| } | |
| /** | |
| * 获取用户权限码 GET /admin/auth/codes | |
| */ | |
| export async function getAccessCodesApi() { | |
| return requestClient.get<string[]>('/admin/auth/codes'); | |
| } | |