juser/change_info/ fix password can be ignore

pull/26/head
liuzheng712 9 years ago
parent 4397819b44
commit 84992746de

@ -433,10 +433,9 @@ def change_info(request):
password = request.POST.get('password', '') password = request.POST.get('password', '')
email = request.POST.get('email', '') email = request.POST.get('email', '')
if '' in [name, password, email]: if '' in [name, email]:
error = '不能为空' error = '不能为空'
if len(password) > 0 and len(password) < 6:
if len(password) < 6:
error = '密码须大于6位' error = '密码须大于6位'
if not error: if not error:
@ -444,8 +443,9 @@ def change_info(request):
# password = CRYPTOR.md5_crypt(password) # password = CRYPTOR.md5_crypt(password)
User.objects.filter(id=user_id).update(name=name, email=email) User.objects.filter(id=user_id).update(name=name, email=email)
user.set_password(password) if len(password) > 0:
user.save() user.set_password(password)
user.save()
msg = '修改成功' msg = '修改成功'
return render_to_response('juser/change_info.html', locals(), context_instance=RequestContext(request)) return render_to_response('juser/change_info.html', locals(), context_instance=RequestContext(request))

@ -41,7 +41,7 @@
</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"> <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">
@ -91,7 +91,7 @@ $('#userForm').validator({
fields: { fields: {
"password": { "password": {
rule: "required;length[6~50]", rule: "length[6~50]",
tip: "输入密码", tip: "输入密码",
ok: "", ok: "",
msg: {required: "必须填写!"} msg: {required: "必须填写!"}

Loading…
Cancel
Save