[Bugfix] 更新用户信息时不填密码也会触发密码规则验证,导致无法更新

pull/1407/head
xiaodong 2018-06-08 16:15:26 +08:00
parent 5464ac8167
commit f4084c800a
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):
password = form.cleaned_data.get('password')
is_ok = check_password_rules(password)
if not is_ok:
form.add_error(
"password", _("* Your password does not meet the requirements")
)
return self.form_invalid(form)
if password:
is_ok = check_password_rules(password)
if not is_ok:
form.add_error(
"password", _("* Your password does not meet the requirements")
)
return self.form_invalid(form)
return super().form_valid(form)