diff --git a/controllers/user.go b/controllers/user.go index 373a4204..f2bb38dd 100644 --- a/controllers/user.go +++ b/controllers/user.go @@ -509,10 +509,21 @@ func (c *ApiController) SetPassword() { return } + organization, err := object.GetOrganizationByUser(targetUser) + if err != nil { + c.ResponseError(err.Error()) + return + } + if organization == nil { + c.ResponseError(fmt.Sprintf(c.T("the organization: %s is not found"), targetUser.Owner)) + return + } + targetUser.Password = newPassword + targetUser.UpdateUserPassword(organization) targetUser.NeedUpdatePassword = false - _, err = object.UpdateUser(userId, targetUser, []string{"password", "need_update_password"}, false) + _, err = object.UpdateUser(userId, targetUser, []string{"password", "need_update_password", "password_type"}, false) if err != nil { c.ResponseError(err.Error()) return