mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 23:47:33 +08:00
make user enter current password when modifying password
This commit is contained in:
+10
-2
@@ -131,8 +131,16 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
||||
userUpdateReq.Email = ""
|
||||
}
|
||||
|
||||
if userUpdateReq.Password != "" && !a.users.IsPasswordEqualsUserPassword(userUpdateReq.Password, user) {
|
||||
anythingUpdate = true
|
||||
if userUpdateReq.Password != "" {
|
||||
if !a.users.IsPasswordEqualsUserPassword(userUpdateReq.OldPassword, user) {
|
||||
return nil, errs.ErrUserPasswordWrong
|
||||
}
|
||||
|
||||
if !a.users.IsPasswordEqualsUserPassword(userUpdateReq.Password, user) {
|
||||
anythingUpdate = true
|
||||
} else {
|
||||
userUpdateReq.Password = ""
|
||||
}
|
||||
} else {
|
||||
userUpdateReq.Password = ""
|
||||
}
|
||||
|
||||
+4
-3
@@ -39,9 +39,10 @@ type UserRegisterRequest struct {
|
||||
}
|
||||
|
||||
type UserProfileUpdateRequest struct {
|
||||
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
|
||||
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
|
||||
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
||||
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
|
||||
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
|
||||
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
||||
OldPassword string `json:"oldPassword" binding:"omitempty,min=6,max=128"`
|
||||
}
|
||||
|
||||
type UserProfileResponse struct {
|
||||
|
||||
Reference in New Issue
Block a user