用户接口调整
This commit is contained in:
parent
300aaf32da
commit
b1b615947c
@ -18,13 +18,23 @@ interface User {
|
||||
registerTime: string;
|
||||
}
|
||||
|
||||
const PasswordSult = '1c3a0b25c3d1c909e2bcb9fe44c2f904';
|
||||
|
||||
function encryptPassword(password: string): string {
|
||||
const md5 = new Md5();
|
||||
return md5.appendStr(`${password}${PasswordSult}`).end() as string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
* @param info
|
||||
* @returns
|
||||
*/
|
||||
export async function register(info: RegisterInfo): Promise<User> {
|
||||
const response = await api.post(`${UserUriBase}/register`, info);
|
||||
const response = await api.post(`${UserUriBase}/register`, {
|
||||
...info,
|
||||
password: encryptPassword(info.password),
|
||||
});
|
||||
return response.data as User;
|
||||
}
|
||||
|
||||
@ -33,21 +43,14 @@ interface LoginInfo {
|
||||
password: string;
|
||||
}
|
||||
|
||||
const PasswordSult = 'sdfs';
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
* @param loginInfo
|
||||
* @returns
|
||||
*/
|
||||
export async function login(loginInfo: LoginInfo): Promise<string> {
|
||||
const md5 = new Md5();
|
||||
const encryptedPassword = md5
|
||||
.appendStr(`${loginInfo.password}${PasswordSult}`)
|
||||
.end();
|
||||
const info = { ...loginInfo, password: encryptedPassword };
|
||||
console.log(info);
|
||||
const response = await api.post(`${UserUriBase}/login`, loginInfo);
|
||||
const info = { ...loginInfo, password: encryptPassword(loginInfo.password) };
|
||||
const response = await api.post(`${UserUriBase}/login`, info);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user