mirror of https://gitee.com/answerdev/answer.git
update modify pass
This commit is contained in:
parent
7603578f31
commit
3e17559623
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"eslint.workingDirectories": [
|
"eslint.workingDirectories": [
|
||||||
"ui"
|
"ui"
|
||||||
]
|
],
|
||||||
|
"commentTranslate.multiLineMerge": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -8925,6 +8925,14 @@ const docTemplate = `{
|
||||||
"pass"
|
"pass"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"captcha_code": {
|
||||||
|
"type": "string",
|
||||||
|
"maxLength": 500
|
||||||
|
},
|
||||||
|
"captcha_id": {
|
||||||
|
"type": "string",
|
||||||
|
"maxLength": 500
|
||||||
|
},
|
||||||
"old_pass": {
|
"old_pass": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 32,
|
"maxLength": 32,
|
||||||
|
|
|
@ -8913,6 +8913,14 @@
|
||||||
"pass"
|
"pass"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"captcha_code": {
|
||||||
|
"type": "string",
|
||||||
|
"maxLength": 500
|
||||||
|
},
|
||||||
|
"captcha_id": {
|
||||||
|
"type": "string",
|
||||||
|
"maxLength": 500
|
||||||
|
},
|
||||||
"old_pass": {
|
"old_pass": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 32,
|
"maxLength": 32,
|
||||||
|
|
|
@ -2134,6 +2134,12 @@ definitions:
|
||||||
type: object
|
type: object
|
||||||
schema.UserModifyPasswordReq:
|
schema.UserModifyPasswordReq:
|
||||||
properties:
|
properties:
|
||||||
|
captcha_code:
|
||||||
|
maxLength: 500
|
||||||
|
type: string
|
||||||
|
captcha_id:
|
||||||
|
maxLength: 500
|
||||||
|
type: string
|
||||||
old_pass:
|
old_pass:
|
||||||
maxLength: 32
|
maxLength: 32
|
||||||
minLength: 8
|
minLength: 8
|
||||||
|
|
|
@ -350,6 +350,21 @@ func (uc *UserController) UserModifyPassWord(ctx *gin.Context) {
|
||||||
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
|
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
|
||||||
req.AccessToken = middleware.ExtractToken(ctx)
|
req.AccessToken = middleware.ExtractToken(ctx)
|
||||||
|
|
||||||
|
captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, schema.ActionRecordTypeModifyPass, ctx.ClientIP(),
|
||||||
|
req.CaptchaID, req.CaptchaCode)
|
||||||
|
if !captchaPass {
|
||||||
|
errFields := append([]*validator.FormErrorField{}, &validator.FormErrorField{
|
||||||
|
ErrorField: "captcha_code",
|
||||||
|
ErrorMsg: translator.Tr(handler.GetLang(ctx), reason.CaptchaVerificationFailed),
|
||||||
|
})
|
||||||
|
handler.HandleResponse(ctx, errors.BadRequest(reason.CaptchaVerificationFailed), errFields)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err := uc.actionService.ActionRecordAdd(ctx, schema.ActionRecordTypeModifyPass, ctx.ClientIP())
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
oldPassVerification, err := uc.userService.UserModifyPassWordVerification(ctx, req)
|
oldPassVerification, err := uc.userService.UserModifyPassWordVerification(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handler.HandleResponse(ctx, err, nil)
|
handler.HandleResponse(ctx, err, nil)
|
||||||
|
@ -363,6 +378,7 @@ func (uc *UserController) UserModifyPassWord(ctx *gin.Context) {
|
||||||
handler.HandleResponse(ctx, errors.BadRequest(reason.OldPasswordVerificationFailed), errFields)
|
handler.HandleResponse(ctx, errors.BadRequest(reason.OldPasswordVerificationFailed), errFields)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.OldPass == req.Pass {
|
if req.OldPass == req.Pass {
|
||||||
errFields := append([]*validator.FormErrorField{}, &validator.FormErrorField{
|
errFields := append([]*validator.FormErrorField{}, &validator.FormErrorField{
|
||||||
ErrorField: "pass",
|
ErrorField: "pass",
|
||||||
|
@ -372,6 +388,9 @@ func (uc *UserController) UserModifyPassWord(ctx *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = uc.userService.UserModifyPassword(ctx, req)
|
err = uc.userService.UserModifyPassword(ctx, req)
|
||||||
|
if err == nil {
|
||||||
|
uc.actionService.ActionRecordDel(ctx, schema.ActionRecordTypeLogin, ctx.ClientIP())
|
||||||
|
}
|
||||||
handler.HandleResponse(ctx, err, nil)
|
handler.HandleResponse(ctx, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,6 +225,7 @@ const (
|
||||||
ActionRecordTypeLogin = "login"
|
ActionRecordTypeLogin = "login"
|
||||||
ActionRecordTypeEmail = "e_mail"
|
ActionRecordTypeEmail = "e_mail"
|
||||||
ActionRecordTypeFindPass = "find_pass"
|
ActionRecordTypeFindPass = "find_pass"
|
||||||
|
ActionRecordTypeModifyPass = "modify_pass"
|
||||||
)
|
)
|
||||||
|
|
||||||
var UserStatusShow = map[int]string{
|
var UserStatusShow = map[int]string{
|
||||||
|
@ -280,6 +281,8 @@ type UserModifyPasswordReq struct {
|
||||||
Pass string `validate:"required,gte=8,lte=32" json:"pass"`
|
Pass string `validate:"required,gte=8,lte=32" json:"pass"`
|
||||||
UserID string `json:"-"`
|
UserID string `json:"-"`
|
||||||
AccessToken string `json:"-"`
|
AccessToken string `json:"-"`
|
||||||
|
CaptchaID string `validate:"omitempty,gt=0,lte=500" json:"captcha_id"`
|
||||||
|
CaptchaCode string `validate:"omitempty,gt=0,lte=500" json:"captcha_code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserModifyPasswordReq) Check() (errFields []*validator.FormErrorField, err error) {
|
func (u *UserModifyPasswordReq) Check() (errFields []*validator.FormErrorField, err error) {
|
||||||
|
|
Loading…
Reference in New Issue