Commit c52e5ed3 by 孙香冬

no message

parent 4e48b817
......@@ -10,14 +10,13 @@ import { BizError } from "../../util/bizError";
const md5 = require("md5");
//登录
/**
*
* @param uscc
* @param pwd
* 登录
* @param uscc 登录账号
* @param pwd 密码
* @returns
*/
export async function login(uscc:string, pwd:string) {
export async function login(uscc:string, pwd:string):Promise<object> {
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.未找到数据);
......@@ -33,14 +32,33 @@ export async function login(uscc:string, pwd:string) {
}
//重置密码
export async function changePassword(uscc:string, pwd:string, newPwd:string) {
if (typeof uscc != "string" || typeof pwd != "string" || typeof newPwd != "string") throw new BizError(ERRORENUM.参数错误, uscc, pwd, newPwd);
let reg = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
if (reg.test(newPwd)) {
throw new BizError("密码不允许有特殊字符");
}
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("密码错误");
fuhuaqiInfo.pwd = getPwdMd5(uscc, newPwd);
await fuhuaqiInfo.save();
return {msg: "修改成功", isOk:true};
}
//退出登录
/**
* 退出登录
* @param uscc 登录账号
* @returns
*/
export async function logout(uscc:string):Promise<object> {
if (typeof uscc != "string") throw new BizError(ERRORENUM.参数错误, uscc);
let fuhuaqiInfo = await fuhuaqiData.findFuHuaQiByUSCC(uscc);
await fuhuaqiInfo.save();
return {isOk:true};
return {msg: "退出成功", isOk:true};
}
function getPwdMd5(uscc:string, pwd:string) {
......
import * as asyncHandler from 'express-async-handler';
import * as fuhuaqiBiz from '../biz/fuHuqQi/user';
export function setRouter(httpServer) {
httpServer.post('/fuhuaqi/login', asyncHandler(login));
......@@ -15,8 +16,9 @@ export function setRouter(httpServer) {
* @param res
*/
async function login(req, res) {
res.success({});
let {uscc, pwd} = req.body;
let fuhuaqiInfo = await fuhuaqiBiz.login(uscc, pwd);
res.success({fuhuaqiInfo});
}
/**
......
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