mirror of https://github.com/msgbyte/tailchat
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.
45 lines
766 B
TypeScript
45 lines
766 B
TypeScript
import { request } from '../api/request';
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* 邮箱注册账号
|
|
* @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;
|
|
}
|