Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zjxcxServer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
zjxcxServer
Commits
c52e5ed3
Commit
c52e5ed3
authored
Feb 06, 2023
by
孙香冬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
4e48b817
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
9 deletions
+29
-9
user.ts
src/biz/fuHuqQi/user.ts
+25
-7
fuhuaqi.ts
src/routers/fuhuaqi.ts
+4
-2
No files found.
src/biz/fuHuqQi/user.ts
View file @
c52e5ed3
...
...
@@ -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
)
{
...
...
src/routers/fuhuaqi.ts
View file @
c52e5ed3
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
});
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment