You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/shared/model/user.ts

57 lines
1010 B
TypeScript

import { request } from '../api/request';
export interface UserLoginInfo {
_id: string;
email: string;
password: string;
token: string;
avatar: string | null;
createdAt: string;
}
/**
* 邮箱登录
* @param email 邮箱
* @param password 密码
*/
export async function loginWithEmail(
email: string,
password: string
): Promise<UserLoginInfo> {
const { data } = await request.post('/api/user/login', {
email,
password,
});
return data;
}
/**
* 使用 Token 登录
* @param token JWT令牌
*/
export async function loginWithToken(token: string): Promise<UserLoginInfo> {
const { data } = await request.post('/api/user/resolveToken', {
token,
});
return data;
}
/**
* 邮箱注册账号
* @param email 邮箱
* @param password 密码
*/
export async function registerWithEmail(
email: string,
password: string
): Promise<UserLoginInfo> {
const { data } = await request.post('/api/user/register', {
email,
password,
});
return data;
}