mirror of https://gitee.com/answerdev/answer.git
fix(admin): add restriction about admin modify their password
This commit is contained in:
parent
66510fcc29
commit
15390adbfc
|
@ -35,6 +35,8 @@ backend:
|
|||
other: Email and password do not match.
|
||||
error:
|
||||
admin:
|
||||
cannot_update_their_password:
|
||||
other: You cannot modify your password.
|
||||
email_or_password_wrong:
|
||||
other: Email and password do not match.
|
||||
answer:
|
||||
|
|
|
@ -64,4 +64,5 @@ const (
|
|||
TagCannotSetSynonymAsItself = "error.tag.cannot_set_synonym_as_itself"
|
||||
NotAllowedRegistration = "error.user.not_allowed_registration"
|
||||
SMTPConfigFromNameCannotBeEmail = "error.smtp.config_from_name_cannot_be_email"
|
||||
AdminCannotUpdateTheirPassword = "error.admin.cannot_update_their_password"
|
||||
)
|
||||
|
|
|
@ -153,6 +153,10 @@ func (us *UserAdminService) AddUser(ctx context.Context, req *schema.AddUserReq)
|
|||
|
||||
// UpdateUserPassword update user password
|
||||
func (us *UserAdminService) UpdateUserPassword(ctx context.Context, req *schema.UpdateUserPasswordReq) (err error) {
|
||||
// Users cannot modify their password
|
||||
if req.UserID == req.LoginUserID {
|
||||
return errors.BadRequest(reason.AdminCannotUpdateTheirPassword)
|
||||
}
|
||||
userInfo, exist, err := us.userRepo.GetUserInfo(ctx, req.UserID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue