fix 密码校验,防止使用弱口令

This commit is contained in:
yxh 2024-08-20 11:36:44 +08:00
parent 6a7829b97a
commit ba7611ff32
3 changed files with 11 additions and 8 deletions

View File

@ -53,7 +53,7 @@ type PersonalEditRes struct {
type PersonalResetPwdReq struct { type PersonalResetPwdReq struct {
g.Meta `path:"/personal/resetPwd" tags:"系统后台/用户管理" method:"put" summary:"重置个人密码"` g.Meta `path:"/personal/resetPwd" tags:"系统后台/用户管理" method:"put" summary:"重置个人密码"`
Password string `p:"password" v:"required|password#密码不能为空|密码以字母开头,只能包含字母、数字和下划线长度在6~18之间"` Password string `p:"password" v:"required|password2#密码不能为空|密码必须包含大小写字母和数字长度在6~18之间"`
commonApi.Author commonApi.Author
} }

View File

@ -67,7 +67,7 @@ type UserAddReq struct {
g.Meta `path:"/user/add" tags:"系统后台/用户管理" method:"post" summary:"添加用户"` g.Meta `path:"/user/add" tags:"系统后台/用户管理" method:"post" summary:"添加用户"`
*SetUserReq *SetUserReq
UserName string `p:"userName" v:"required#用户账号不能为空"` UserName string `p:"userName" v:"required#用户账号不能为空"`
Password string `p:"password" v:"required|password#密码不能为空|密码以字母开头,只能包含字母、数字和下划线长度在6~18之间"` Password string `p:"password" v:"required|password2#密码不能为空|密码必须包含大小写字母和数字长度在6~18之间"`
UserSalt string UserSalt string
} }
@ -100,7 +100,7 @@ type UserGetEditRes struct {
type UserResetPwdReq struct { type UserResetPwdReq struct {
g.Meta `path:"/user/resetPwd" tags:"系统后台/用户管理" method:"put" summary:"重置用户密码"` g.Meta `path:"/user/resetPwd" tags:"系统后台/用户管理" method:"put" summary:"重置用户密码"`
Id uint64 `p:"userId" v:"required#用户id不能为空"` Id uint64 `p:"userId" v:"required#用户id不能为空"`
Password string `p:"password" v:"required|password#密码不能为空|密码以字母开头,只能包含字母、数字和下划线长度在6~18之间"` Password string `p:"password" v:"required|password2#密码不能为空|密码必须包含大小写字母和数字长度在6~18之间"`
} }
type UserResetPwdRes struct { type UserResetPwdRes struct {

View File

@ -22,10 +22,13 @@ func (s *Local) Upload(ctx context.Context, file *ghttp.UploadFile) (result syst
return return
} }
r := g.RequestFromCtx(ctx) r := g.RequestFromCtx(ctx)
host := r.Host host := r.Header.Get("X-Forwarded-Host")
forwardedHost := r.Header.Get("X-Forwarded-Host") scheme := r.Header.Get("X-Scheme")
if forwardedHost != "" { if host == "" {
host = forwardedHost host = r.Host
}
if scheme == "" {
scheme = r.GetSchema()
} }
uri := r.Header.Get("X-Original-URI") uri := r.Header.Get("X-Original-URI")
if uri != "" { if uri != "" {
@ -34,7 +37,7 @@ func (s *Local) Upload(ctx context.Context, file *ghttp.UploadFile) (result syst
uri = gstr.SubStr(uri, 1, pos) uri = gstr.SubStr(uri, 1, pos)
} }
} }
urlPerfix := fmt.Sprintf("//%s/%s", host, uri) urlPerfix := fmt.Sprintf("%s://%s/%s", scheme, host, uri)
p := strings.Trim(consts.UploadPath, "/") p := strings.Trim(consts.UploadPath, "/")
sp := s.getStaticPath(ctx) sp := s.getStaticPath(ctx)
if sp != "" { if sp != "" {