修正:修改密码会失败的问题。

pull/32/head v2.2.6.1-hotfix-2
Apex Liu 2017-04-19 18:44:07 +08:00
parent 32e0991164
commit 94aebc3277
2 changed files with 49 additions and 48 deletions

View File

@ -142,18 +142,19 @@ class ModifyPwd(TPBaseUserAuthJsonHandler):
if args is not None: if args is not None:
args = json.loads(args) args = json.loads(args)
else: else:
self.write_json(-1) self.write_json(-11)
return return
_old_pwd = args['o_pwd'] _old_pwd = args['o_pwd']
_new_pwd = args['n_pwd'] _new_pwd = args['n_pwd']
if _old_pwd is None or _new_pwd is None: if _old_pwd is None or _new_pwd is None:
self.write_json(-1) self.write_json(-12)
return return
user_info = self.get_current_user() user_info = self.get_current_user()
try: try:
ret = user.modify_pwd(_old_pwd, _new_pwd, user_info['id']) ret = user.modify_pwd(_old_pwd, _new_pwd, user_info['id'])
self.write_json(0, ret) self.write_json(ret)
except: except:
self.write_json(-1) log.e('modify password failed.')
self.write_json(-13)

View File

@ -1,45 +1,45 @@
/** /**
* Created by mi on 2016/7/4. * Created by mi on 2016/7/4.
*/ */
ywl.clear_input = function() { ywl.clear_input = function() {
$("#current-pwd").val(''); $("#current-pwd").val('');
$("#new-pwd-1").val(''); $("#new-pwd-1").val('');
$("#new-pwd-2").val(''); $("#new-pwd-2").val('');
}; };
ywl.on_init = function (cb_stack, cb_args) { ywl.on_init = function (cb_stack, cb_args) {
$("#btn-modify-pwd").click(function () { $("#btn-modify-pwd").click(function () {
var old_pwd = $("#current-pwd").val(); var old_pwd = $("#current-pwd").val();
var new_pwd_1 = $("#new-pwd-1").val(); var new_pwd_1 = $("#new-pwd-1").val();
var new_pwd_2 = $("#new-pwd-2").val(); var new_pwd_2 = $("#new-pwd-2").val();
if(old_pwd.length == 0) { if(old_pwd.length == 0) {
ywl.notify_error('请输入当前密码!'); ywl.notify_error('请输入当前密码!');
return; return;
} }
if(new_pwd_1.length == 0) { if(new_pwd_1.length == 0) {
ywl.notify_error('请设置新密码!'); ywl.notify_error('请设置新密码!');
return; return;
} }
if (new_pwd_1 != new_pwd_2) { if (new_pwd_1 != new_pwd_2) {
ywl.notify_error('两次密码输入不一致!'); ywl.notify_error('两次密码输入不一致!');
return; return;
} }
ywl.ajax_post_json('/auth/modify-pwd', {o_pwd: old_pwd, n_pwd: new_pwd_1, callback: 1}, ywl.ajax_post_json('/auth/modify-pwd', {o_pwd: old_pwd, n_pwd: new_pwd_1, callback: 1},
function (ret) { function (ret) {
if (ret.data.code == 0) { if (ret.code == 0) {
ywl.notify_success('密码修改成功!'); ywl.notify_success('密码修改成功!');
ywl.clear_input(); ywl.clear_input();
} else if (ret.data.code == -2) { } else if (ret.code == -2) {
ywl.notify_error('密码错误!'); ywl.notify_error('密码错误!');
} else { } else {
ywl.notify_error('密码修改失败!'); ywl.notify_error('密码修改失败!errcode:'+ret.code);
} }
}, },
function () { function () {
ywl.notify_error('密码修改失败!'); ywl.notify_error('密码修改失败!');
} }
); );
}); });
}; };