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('username', username, expires=604800)
# response.set_cookie('seed', PyCrypt.md5_crypt(password), expires=604800) # response.set_cookie('seed', PyCrypt.md5_crypt(password), expires=604800)
# return response # return response
# else: else:
# error = '密码错误,请重新输入。' error = '用户名或密码错误'
else: else:
error = '用户名或密码错误' error = '用户名或密码错误'
return render_to_response('login.html', {'error': 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_id = kwargs.pop('user_id')
user = User.objects.get(id=user_id) user = User.objects.get(id=user_id)
if user: if user:
pwd = kwargs.pop('password')
user.update(**kwargs) user.update(**kwargs)
user.set_password(kwargs.pop('password')) if pwd != '':
user.set_password(pwd)
user.save() user.save()
else: else:
return None return None

View File

@ -38,9 +38,9 @@
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> <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"> <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"> <span class="help-block m-b-none">
登陆web的密码 登陆web的密码
</span> </span>
@ -155,7 +155,7 @@ $('#userForm').validator({
msg: {required: "必须填写!"} msg: {required: "必须填写!"}
}, },
"password": { "password": {
rule: "required;length[6~50]", rule: "length[6~50]",
tip: "输入密码", tip: "输入密码",
ok: "", ok: "",
msg: {required: "必须填写!"} msg: {required: "必须填写!"}