Commit c02e08fa by 孙香冬

no message

parent 9e346ab2
......@@ -3,3 +3,39 @@
* 主要包括有 孵化器账号的登录
* 预留好 重置密码 退出登录 接口
*/
import { ERRORENUM } from "../../config/errorEnum";
import * as fuhuaqiData from "../../data/fuHuaQi/fuhuaqi"
import { BizError } from "../../util/bizError";
const md5 = require("md5");
//登录
export async function login(uscc:string, pwd:string) {
if (typeof uscc != "string" || typeof pwd != "string") throw new BizError(ERRORENUM.参数错误, uscc, pwd);
let fuhuaqiInfo = await fuhuaqiData.findFuHuaQiByUSCC(uscc);
if(!fuhuaqiInfo) throw new BizError(ERRORENUM.未找到数据);
let checkPwd = getPwdMd5(fuhuaqiInfo.uscc, pwd);
if (fuhuaqiInfo.pwd != checkPwd) throw new BizError("密码不正确");
let fuhuaqiUserInfo = {
uscc: fuhuaqiInfo.uscc,
name: fuhuaqiInfo.name
};
return fuhuaqiUserInfo;
}
//重置密码
//退出登录
export async function logout(uscc:string) {
if (typeof uscc != "string") throw new BizError(ERRORENUM.参数错误, uscc);
let fuhuaqiInfo = await fuhuaqiData.findFuHuaQiByUSCC(uscc);
await fuhuaqiInfo.save();
return {isOk:true};
}
function getPwdMd5(uscc:string, pwd:string) {
return md5(uscc+pwd);
}
\ No newline at end of file
......@@ -38,3 +38,4 @@ export async function findFuHuaQiByUSCC(uscc:string) {
export async function findFuHuaQiByName(name:string) {
return await fuHuaQiModel.findOne({name}).exec();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment