set user password , if you don't want to change the password , leave password empty

pull/26/head
liuzheng712 2015-11-05 14:30:59 +08:00
parent 6934380b9c
commit 09087a4d8f
3 changed files with 8 additions and 6 deletions

View File

@ -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})

View File

@ -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

View File

@ -38,9 +38,9 @@
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">密码<span class="red-fonts">*</span></label>
<label for="password" class="col-sm-2 control-label">密码</label>
<div class="col-sm-8">
<input id="password" name="password" placeholder="Password" type="password" class="form-control" value="{{ user.password }}">
<input id="password" name="password" placeholder="Password" type="password" class="form-control">
<span class="help-block m-b-none">
登陆web的密码
</span>
@ -155,7 +155,7 @@ $('#userForm').validator({
msg: {required: "必须填写!"}
},
"password": {
rule: "required;length[6~50]",
rule: "length[6~50]",
tip: "输入密码",
ok: "",
msg: {required: "必须填写!"}