From 17e1fe2acb961e56eb302a2c4868edd82176c7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AB=E5=8D=83=E6=B5=81?= <40739051+jym503558564@users.noreply.github.com> Date: Thu, 4 Jul 2019 16:13:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8DinitDataTable?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=90=9C=E7=B4=A2=E6=A0=8F=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=8F=8B=E5=A5=BD=E9=97=AE=E9=A2=98=20(#2880?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/static/js/jumpserver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/static/js/jumpserver.js b/apps/static/js/jumpserver.js index a90ccd64c..1dfa1d5b4 100644 --- a/apps/static/js/jumpserver.js +++ b/apps/static/js/jumpserver.js @@ -472,7 +472,7 @@ jumpserver.initDataTable = function (options) { }; var table = ele.DataTable({ pageLength: options.pageLength || 15, - dom: options.dom || '<"#uc.pull-left">flt<"row m-t"<"col-md-8"<"#op.col-md-6"><"col-md-6 text-center"i>><"col-md-4"p>>', + dom: options.dom || '<"#uc.pull-left"><"pull-right"<"inline"l><"#fb.inline"><"inline"f><"#fa.inline">>tr<"row m-t"<"col-md-8"<"#op.col-md-6"><"col-md-6 text-center"i>><"col-md-4"p>>', order: options.order || [], // select: options.select || 'multi', searchDelay: 800, From 3598bc79c3c1598e367441584d0b099ac806b027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AB=E5=8D=83=E6=B5=81?= <40739051+jym503558564@users.noreply.github.com> Date: Thu, 4 Jul 2019 16:14:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=94=A8=E6=88=B7=E7=9A=84View,=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E5=88=9B=E5=BB=BA=E7=94=A8=E6=88=B7=E6=97=B6?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=A0=A1=E9=AA=8C=E5=AF=86=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E5=88=99=20(#2877)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Bugfix] 修复创建用户的View,使用密码创建用户时没有校验密码规则 * [Bugfix]修复小问题 * [Update] 优化创建用户和更新用户密码的校验 * [Update] 优化用户表单校验password逻辑 * [Update] 小问题 --- apps/users/forms.py | 15 +++++++++++++++ apps/users/views/user.py | 13 ------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/users/forms.py b/apps/users/forms.py index 423aa81e1..96357c7b5 100644 --- a/apps/users/forms.py +++ b/apps/users/forms.py @@ -7,6 +7,7 @@ from common.utils import validate_ssh_public_key from orgs.mixins import OrgModelForm from orgs.utils import current_org from .models import User, UserGroup +from .utils import check_password_rules class UserCheckPasswordForm(forms.Form): @@ -90,6 +91,20 @@ class UserCreateUpdateFormMixin(OrgModelForm): raise forms.ValidationError(_('Not a valid ssh public key')) return public_key + def clean_password(self): + password_strategy = self.data.get('password_strategy') + # 创建-不设置密码 + if password_strategy == '0': + return + password = self.data.get('password') + # 更新-密码为空 + if password_strategy is None and not password: + return + if not check_password_rules(password): + msg = _('* Your password does not meet the requirements') + raise forms.ValidationError(msg) + return password + def save(self, commit=True): password = self.cleaned_data.get('password') otp_level = self.cleaned_data.get('otp_level') diff --git a/apps/users/views/user.py b/apps/users/views/user.py index ff9e03530..ea599225e 100644 --- a/apps/users/views/user.py +++ b/apps/users/views/user.py @@ -133,19 +133,6 @@ class UserUpdateView(PermissionsMixin, SuccessMessageMixin, UpdateView): kwargs.update(context) return super().get_context_data(**kwargs) - def form_valid(self, form): - password = form.cleaned_data.get('password') - if not password: - return super().form_valid(form) - - 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) - def get_form_kwargs(self): kwargs = super(UserUpdateView, self).get_form_kwargs() data = {'request': self.request}