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

login\pass change fix

parent 11415bd1
Branches
Tags
No related merge requests found
var $ = jQuery;
$(function() {
var jInputLogin = $(".inputLogin").first();
var jChangeLogin = $(".changeLogin").first();
var jChangePass = $(".changePass").first();
$('.showBlockReport').click(function(){
if ($('.blockReport').css('display') == 'none')
$('.blockReport').slideDown("fast");
......@@ -20,19 +25,32 @@ $(function() {
var checkInput = new Array(); // Массив с ключами валидации (true/false)
$('.changeLogin').click(function(){
if (/^[a-zA-Z0-9]+$/.test($('.inputLogin').val()))
var login = jInputLogin.val();
jChangeLogin.attr("disabled", true);
if (/^[a-zA-Z0-9]+$/.test(login))
checkInput['login'] = true;
else checkInput['login'] = false;
else
checkInput['login'] = false;
if (checkInput['login'] == true)
$.post(URLdir + 'handler/settings/changeLogin', {'login': $('.inputLogin').val()},
if (checkInput['login'] === true) {
jInputLogin.attr("disabled", true);
$.post(URLdir + 'handler/settings/changeLogin', {'login': login},
function(data){
data = $.parseJSON(data);
jInputLogin.removeAttr("disabled");
jChangeLogin.removeAttr("disabled");
if(data.success === true) {
EventInspector_ShowMsg('Логин изменен', 'success');
} else EventInspector_ShowMsg('Не удалось изменить логин', 'error');
jInputLogin.bind("keydown", function(event){ event.preventDefault(); });
jChangeLogin.html("Логин изменен!").unbind("click");
} else
EventInspector_ShowMsg('Не удалось изменить логин', 'error');
}
);
}
});
$('.changeEmail').click(function(){
......@@ -50,7 +68,8 @@ $(function() {
*/
});
$('.changePass').click(function(){
jChangePass.click(function(){
jChangePass.attr("disabled", true);
if ($.trim($('.inputCurrentPass').val()) != '')
checkInput['currentPass'] = true;
else checkInput['currentPass'] = false;
......@@ -73,8 +92,10 @@ $(function() {
},
function(data){
data = $.parseJSON(data);
jChangeLogin.removeAttr("disabled");
if(data.success === true) {
EventInspector_ShowMsg('Пароль изменен', 'success');
jChangePass.html("Пароль изменен!").unbind("click");
} else EventInspector_ShowMsg('Не удалось изменить пароль', 'error');
}
);
......
......@@ -187,7 +187,7 @@ class Kohana_User implements ArrayAccess {
{
if(!$this->checkPassword($old))
return FALSE;
$this->_model->changePassword($this->offsetGet('AccID'), sha1($new));
$this->_model->changePassword($this->offsetGet('ID'), sha1($new));
$passhash = $this->hash($this->hash($new).$this->_config['hash_key']);
Cookie::set('userhash', $passhash);
$this->_session->set('PasswordHash', $passhash);
......@@ -198,7 +198,7 @@ class Kohana_User implements ArrayAccess {
{
if(!$this->isSignedIn() || Account::instance()->isLoginExists($login))
return FALSE;
$this->_model->changeLogin($this->offsetGet('AccID'), $login);
$this->_model->changeLogin($this->offsetGet('ID'), $login);
return TRUE;
}
......@@ -217,7 +217,7 @@ class Kohana_User implements ArrayAccess {
$email = $this->_session->get('NewMail_Adress');
if($token == $this->_session->get('NewMail_Token') AND !Account::instance()->isMailExists($email))
{
$this->_model->changeMail($this->offsetGet('AccID'), $email);
$this->_model->changeMail($this->offsetGet('ID'), $email);
return true;
}
else {
......
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