用户接口调整

This commit is contained in:
sheng 2023-06-02 23:32:00 +08:00
parent 300aaf32da
commit b1b615947c

View File

@ -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;
}