修改密码强度验证
This commit is contained in:
parent
58c5f8455d
commit
0bee1fa40c
@ -176,8 +176,8 @@ func (r *Dept) PutDept(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
apiService := service.DeptService{}
|
||||
_, err = apiService.PutDept(deptId, deptRequest.PutDept)
|
||||
deptService := service.DeptService{}
|
||||
_, err = deptService.PutDept(deptId, deptRequest.PutDept)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
|
||||
@ -160,14 +160,14 @@ func (r *Post) DeletePost(c *gin.Context) {
|
||||
|
||||
// PutPost 修改部门
|
||||
func (r *Post) PutPost(c *gin.Context) {
|
||||
deptRequest := requests.PostRequest{}
|
||||
if err := c.ShouldBind(&deptRequest.PutPost); err != nil {
|
||||
postRequest := requests.PostRequest{}
|
||||
if err := c.ShouldBind(&postRequest.PutPost); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(deptRequest.PutPost); err != nil {
|
||||
if err := global.Validate.Struct(postRequest.PutPost); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
@ -199,8 +199,8 @@ func (r *Post) PutPost(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
apiService := service.PostService{}
|
||||
_, err = apiService.PutPost(postId, deptRequest.PutPost)
|
||||
postService := service.PostService{}
|
||||
_, err = postService.PutPost(postId, postRequest.PutPost)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
"regexp"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@ -350,6 +351,28 @@ func (r *UserService) PutUserPassword(requestUserId int64, putUserPasswordReques
|
||||
return false, errors.New("原密码错误,请重新输入")
|
||||
}
|
||||
|
||||
// 密码校验
|
||||
if len(putUserPasswordRequest.NewPassword) < 8 {
|
||||
return false, errors.New("密码小于8位数")
|
||||
}
|
||||
|
||||
num := `[0-9]{1}`
|
||||
a_z := `[a-z]{1}`
|
||||
A_Z := `[A-Z]{1}`
|
||||
symbol := `[!@#.~$%^&*()+|_]{1}`
|
||||
if b, err := regexp.MatchString(num, putUserPasswordRequest.NewPassword); !b || err != nil {
|
||||
return false, errors.New("密码强度必须为字⺟⼤⼩写+数字+符号")
|
||||
}
|
||||
if b, err := regexp.MatchString(a_z, putUserPasswordRequest.NewPassword); !b || err != nil {
|
||||
return false, errors.New("密码强度必须为字⺟⼤⼩写+数字+符号")
|
||||
}
|
||||
if b, err := regexp.MatchString(A_Z, putUserPasswordRequest.NewPassword); !b || err != nil {
|
||||
return false, errors.New("密码强度必须为字⺟⼤⼩写+数字+符号")
|
||||
}
|
||||
if b, err := regexp.MatchString(symbol, putUserPasswordRequest.NewPassword); !b || err != nil {
|
||||
return false, errors.New("密码强度必须为字⺟⼤⼩写+数字+符号")
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user