diff --git a/codepot/src/codepot/controllers/main.php b/codepot/src/codepot/controllers/main.php index b0808abd..6eb4981a 100644 --- a/codepot/src/codepot/controllers/main.php +++ b/codepot/src/codepot/controllers/main.php @@ -20,6 +20,33 @@ class Main extends Controller redirect ("main/signin/$xurl"); } + function xhr_signin () + { + $this->load->model ('UserModel', 'users'); + + if($this->input->post('user_name')) + { + $user_name = $this->input->post('user_name'); + $user_pass = $this->input->post('user_pass'); + + if ($this->login->authenticate ($user_name, $user_pass) === FALSE) + { + print 'error - ' . $this->login->getErrorMessage(); + } + else + { + $settings = $this->users->fetchSettings ($user_name); + if ($settings !== FALSE) $this->login->setUserSettings ($settings); + print 'ok'; + } + } + else + { + $this->login->deauthenticate (); + print 'ok'; + } + } + function signin ($xurl = '') { $this->load->model ('UserModel', 'users'); diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index c9e9597b..c45c88f4 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -130,6 +130,7 @@ $lang['MSG_NO_SUCH_PROJECT'] = 'No such project'; $lang['MSG_SURE_TO_DELETE_THIS'] = "I'm sure to delete this"; $lang['MSG_FAILED_TO_READ_FILE'] = 'Failed to read file - %s'; $lang['MSG_NO_SUCH_FILE'] = 'No such file - %s'; +$lang['MSG_SIGNIN_FAILURE'] = 'Cannot sign in'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index fc4ce2fb..94b79561 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -127,6 +127,7 @@ $lang['MSG_NO_SUCH_PROJECT'] = 'No such project'; $lang['MSG_SURE_TO_DELETE_THIS'] = "Saya yakin untuk menghapus"; $lang['MSG_FAILED_TO_READ_FILE'] = 'Failed to read file - %s'; $lang['MSG_NO_SUCH_FILE'] = 'No such file - %s'; +$lang['MSG_SIGNIN_FAILURE'] = 'Cannot sign in'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index 5e902cac..5a59ec8f 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -130,6 +130,7 @@ $lang['MSG_NO_SUCH_PROJECT'] = '프로젝트가 없습니다'; $lang['MSG_SURE_TO_DELETE_THIS'] = '반드시 이것을 삭제하고 싶어요'; $lang['MSG_FAILED_TO_READ_FILE'] = '파일을 읽을 수 없습니다 - %s'; $lang['MSG_NO_SUCH_FILE'] = '파일이 없습니다 - %s'; +$lang['MSG_SIGNIN_FAILURE'] = '로그인할 수 없습니다'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = '이 작업을 수행하려면 %s 프로젝트의 멤버가 되어야 합니다'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = '입력이 완전하지 않습니다'; diff --git a/codepot/src/codepot/models/dbloginmodel.php b/codepot/src/codepot/models/dbloginmodel.php index 8d5837a6..8fd50934 100644 --- a/codepot/src/codepot/models/dbloginmodel.php +++ b/codepot/src/codepot/models/dbloginmodel.php @@ -36,7 +36,7 @@ class DbLoginModel extends LoginModel function authenticate ($userid, $passwd) { - $this->db->trans_start (); + $this->db->trans_begin (); $this->db->select ('userid,passwd,email'); $this->db->where ('userid', $userid); @@ -45,27 +45,36 @@ class DbLoginModel extends LoginModel if ($this->db->trans_status() == FALSE) { - $this->db->trans_complete (); + $this->setErrorMessage ($this->db->_error_message()); + $this->db->trans_rollback (); return FALSE; } $result = $query->result (); if (empty($result)) { - $this->db->trans_complete (); + $this->setErrorMessage ('invalid credential'); // no such user name + $this->db->trans_rollback (); return FALSE; } - $this->db->trans_complete (); - if ($this->db->trans_status() == FALSE) return FALSE; + $this->db->trans_commit(); $user = $result[0]; - if (strlen($user->passwd) < 10) return FALSE; + if (strlen($user->passwd) < 10) + { + $this->setErrorMessage ('wrongly formatted password'); + return FALSE; + } // the last 10 characters are the salt. $hexsalt = substr ($user->passwd, -10); $binsalt = pack('H*' , $hexsalt); - if (strcmp ($this->format_password_with_salt($passwd,$binsalt),$user->passwd) != 0) return FALSE; + if (strcmp ($this->format_password_with_salt($passwd,$binsalt),$user->passwd) != 0) + { + $this->setErrorMessage ('invalid credential'); // invalid password + return FALSE; + } return parent::authenticate ($userid, $user->passwd, $user->email); } @@ -80,6 +89,7 @@ class DbLoginModel extends LoginModel if ($this->db->trans_status() === FALSE) { + $this->setErrorMessage ($this->db->_error_message()); $this->db->trans_rollback (); return FALSE; } @@ -98,6 +108,7 @@ class DbLoginModel extends LoginModel if ($this->db->trans_status() == FALSE) { + $this->setErrorMessage ($this->db->_error_message()); $this->db->trans_complete (); return FALSE; } diff --git a/codepot/src/codepot/views/code_folder.php b/codepot/src/codepot/views/code_folder.php index 14abecf0..bd9c08ed 100644 --- a/codepot/src/codepot/views/code_folder.php +++ b/codepot/src/codepot/views/code_folder.php @@ -699,7 +699,6 @@ $(function () { } }, 'lang->line('Cancel')?>': function () { - if (import_in_progress) return; $('#code_folder_search').dialog('close'); } } diff --git a/codepot/src/codepot/views/taskbar.php b/codepot/src/codepot/views/taskbar.php index c2976a04..f37496ab 100644 --- a/codepot/src/codepot/views/taskbar.php +++ b/codepot/src/codepot/views/taskbar.php @@ -39,65 +39,30 @@ function show_taskbar ($con, $login) print ' '; - //print form_submit ( - // 'login', - // $con->lang->line('Sign out'), - // 'class="button" id="taskbar_signinout_button"' - //); printf ('%s', $con->lang->line('Sign out')); print form_close(); } else { - print form_open('main/signin', array('id' => 'taskbar_signinout_form')); + print '