From 09087a4d8f64a4aec50b6235f3839a4813a91eac Mon Sep 17 00:00:00 2001 From: liuzheng712 Date: Thu, 5 Nov 2015 14:30:59 +0800 Subject: [PATCH] set user password , if you don't want to change the password , leave password empty --- jumpserver/views.py | 4 ++-- juser/user_api.py | 4 +++- templates/juser/user_edit.html | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/jumpserver/views.py b/jumpserver/views.py index 692c718e7..379a35489 100644 --- a/jumpserver/views.py +++ b/jumpserver/views.py @@ -227,8 +227,8 @@ def Login(request): # response.set_cookie('username', username, expires=604800) # response.set_cookie('seed', PyCrypt.md5_crypt(password), expires=604800) # return response - # else: - # error = '密码错误,请重新输入。' + else: + error = '用户名或密码错误' else: error = '用户名或密码错误' return render_to_response('login.html', {'error': error}) diff --git a/juser/user_api.py b/juser/user_api.py index f90cbbaf9..5ff4f07e3 100644 --- a/juser/user_api.py +++ b/juser/user_api.py @@ -86,8 +86,10 @@ def db_update_user(**kwargs): user_id = kwargs.pop('user_id') user = User.objects.get(id=user_id) if user: + pwd = kwargs.pop('password') user.update(**kwargs) - user.set_password(kwargs.pop('password')) + if pwd != '': + user.set_password(pwd) user.save() else: return None diff --git a/templates/juser/user_edit.html b/templates/juser/user_edit.html index a9b353d67..5b9e537c4 100644 --- a/templates/juser/user_edit.html +++ b/templates/juser/user_edit.html @@ -38,9 +38,9 @@
- +
- + 登陆web的密码 @@ -155,7 +155,7 @@ $('#userForm').validator({ msg: {required: "必须填写!"} }, "password": { - rule: "required;length[6~50]", + rule: "length[6~50]", tip: "输入密码", ok: "", msg: {required: "必须填写!"}