Skip to content
Snippets Groups Projects
Commit e15dacba authored by PavelBegunkov's avatar PavelBegunkov
Browse files

change password js fix

parent 8882ad4c
Branches
Tags
No related merge requests found
......@@ -33,17 +33,12 @@ $(function()
});
function closeSession(time) {
if (time < 0)
time = 0;
setTimeout(function() {
$.ajax({
type: "POST",
url: URLdir + "handler/Session/closeSession",
success: function(data) {window.location.replace(URLdir);}
});
}, time*1000);
function closeSession() {
$.ajax({
type: "POST",
url: URLdir + "handler/Session/closeSession",
success: function(data) {window.location.replace(URLdir);}
});
}
......
......@@ -5,6 +5,10 @@ $(function() {
var jChangeLogin = $(".changeLogin").first();
var jChangePass = $(".changePass").first();
var jInputPwdCurrent = $('.inputCurrentPass').first();
var jInputPwdNew = $('.inputNewPass').first();
var jInputPwdConfirm = $('.inputСonfirmPass').first();
$('.showBlockReport').click(function(){
if ($('.blockReport').css('display') == 'none')
$('.blockReport').slideDown("fast");
......@@ -68,36 +72,43 @@ $(function() {
*/
});
jChangePass.click(function(){
jChangePass.click(function() {
jChangePass.attr("disabled", true);
if ($.trim($('.inputCurrentPass').val()) != '')
checkInput['currentPass'] = true;
else checkInput['currentPass'] = false;
if ($.trim($('.inputNewPass').val()) != '')
checkInput['newPass'] = true;
else checkInput['newPass'] = false;
if (checkInput['currentPass'] == true && checkInput['newPass'] == true && $('.inputСonfirmPass').val() == $('.inputNewPass').val())
checkInput['confirmPass'] = true;
else
checkInput['confirmPass'] = false;
if (checkInput['confirmPass'] == true)
$.post(URLdir + 'handler/settings/changePassword',
{
'old_password': $.sha1($('.inputCurrentPass').val()),
'password': $.sha1($('.inputNewPass').val()),
'confirm_password': $.sha1($('.inputСonfirmPass').val())
},
function(data){
data = $.parseJSON(data);
jChangeLogin.removeAttr("disabled");
if(data.success === true) {
EventInspector_ShowMsg('Пароль изменен', 'success');
jChangePass.html("Пароль изменен!").unbind("click");
} else EventInspector_ShowMsg('Не удалось изменить пароль', 'error');
}
);
var pwdCurrent = $.trim(jInputPwdCurrent.val());
var pwdConfirm = $.trim(jInputPwdConfirm.val());
var pwdNew = $.trim(jInputPwdNew.val());
if (pwdCurrent === '' || pwdNew === '' || pwdNew !== pwdConfirm) {
EventInspector_ShowMsg('Не удалось изменить пароль', 'error');
jChangePass.removeAttr("disabled");
return;
}
$.post(URLdir + 'handler/settings/changePassword',
{
'old_password': $.sha1(pwdCurrent),
'password': $.sha1(pwdNew),
'confirm_password': $.sha1(pwdConfirm)
},
function(data) {
data = $.parseJSON(data);
if(data.success === true) {
EventInspector_ShowMsg('Пароль изменен', 'success');
jChangePass.html("Пароль изменен!").unbind("click");
jInputPwdCurrent.attr("disabled", true);
jInputPwdConfirm.attr("disabled", true);
jInputPwdNew.attr("disabled", true);
} else
EventInspector_ShowMsg('Не удалось изменить пароль', 'error');
jChangePass.removeAttr("disabled");
}
);
});
});
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment