mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 19:46:38 +08:00
2e636ce43f
- 新增创建临时登录密码的 API 请求 - 新增电视端临时登录密码弹窗组件并在用户菜单中提供入口 - 在个人资料页面添加电视临时登录码生成与倒计时展示
26 lines
831 B
TypeScript
26 lines
831 B
TypeScript
import { api } from './client'
|
|
import type { User, TokenPair } from '../types'
|
|
|
|
export interface LoginResponse {
|
|
user: User
|
|
tokens: TokenPair
|
|
}
|
|
|
|
export const authAPI = {
|
|
login: (username: string, password: string) =>
|
|
api.post<LoginResponse>('/auth/login', { username, password }).then((r) => r.data),
|
|
|
|
register: (username: string, password: string) =>
|
|
api.post<LoginResponse>('/auth/register', { username, password }).then((r) => r.data),
|
|
|
|
me: () => api.get<User>('/me').then((r) => r.data),
|
|
|
|
changePassword: (oldPassword: string, newPassword: string) =>
|
|
api
|
|
.post('/me/password', { old_password: oldPassword, new_password: newPassword })
|
|
.then((r) => r.data),
|
|
|
|
createTemporaryPassword: () =>
|
|
api.post<{ code: string; expires_in: number }>('/me/temporary-password').then((r) => r.data),
|
|
}
|