Merge pull request #1407 from jokimina/dev_for_pr

[Bugfix] 更新用户信息时不填密码也会触发密码规则验证,导致无法更新
pull/1413/head^2^2
老广 2018-06-08 05:31:05 -05:00 committed by GitHub
commit 8a5e1b8223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -109,12 +109,13 @@ class UserUpdateView(AdminUserRequiredMixin, SuccessMessageMixin, UpdateView):
def form_valid(self, form): def form_valid(self, form):
password = form.cleaned_data.get('password') password = form.cleaned_data.get('password')
is_ok = check_password_rules(password) if password:
if not is_ok: is_ok = check_password_rules(password)
form.add_error( if not is_ok:
"password", _("* Your password does not meet the requirements") form.add_error(
) "password", _("* Your password does not meet the requirements")
return self.form_invalid(form) )
return self.form_invalid(form)
return super().form_valid(form) return super().form_valid(form)