Changeset 111
- Timestamp:
- 04/19/07 09:53:21
- Files:
-
- FreakAuth/trunk/www/system/application/config/freakauth_light.php (modified) (1 diff)
- FreakAuth/trunk/www/system/application/controllers/auth.php (modified) (2 diffs)
- FreakAuth/trunk/www/system/application/libraries/FAL_validation.php (modified) (3 diffs)
- FreakAuth/trunk/www/system/application/views/FreakAuth_light/content/login.php (modified) (3 diffs)
- FreakAuth/trunk/www/system/language/english/freakauth_lang.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
FreakAuth/trunk/www/system/application/config/freakauth_light.php
r93 r111 116 116 117 117 // LOGIN 118 $config['FAL_user_name_field_validation_login'] = 'trim|required|xss_clean |username_login_check'; //name in login119 $config['FAL_user_password_field_validation_login'] = 'trim|required|xss_clean |password_login_check'; //password in login118 $config['FAL_user_name_field_validation_login'] = 'trim|required|xss_clean'; //name in login 119 $config['FAL_user_password_field_validation_login'] = 'trim|required|xss_clean'; //password in login 120 120 121 121 // REGISTRATION FreakAuth/trunk/www/system/application/controllers/auth.php
r93 r111 100 100 $rules['user_name'] = $this->config->item('FAL_user_name_field_validation_login'); 101 101 $rules['password'] = $this->config->item('FAL_user_password_field_validation_login'); 102 $rules['username_password'] = ''; 102 103 103 104 //------------------------------------- … … 113 114 $this->fal_validation->set_rules($rules); 114 115 116 //let's run the individual validation of username and password 117 $validation_response = $this->fal_validation->run(); 118 119 //if you change the keys of the validation rules 120 //remember to adjust the following 2 lines 121 //i.e. change $this->fal_validation->user_name to $this->fal_validation->your_user_name_key 122 echo $username_login = $this->fal_validation->user_name; 123 echo $password_login = $this->fal_validation->password; 124 115 125 //everything went ok, let's log the user in and redirect him to the homepage 116 if ($ this->fal_validation->run() && $this->freakauth_light->login())126 if ($validation_response==TRUE && $this->fal_validation->login_check($username_login, $password_login) && $this->freakauth_light->login()) 117 127 { 118 128 $role= $this->db_session->userdata('role'); FreakAuth/trunk/www/system/application/libraries/FAL_validation.php
r108 r111 56 56 57 57 // -------------------------------------------------------------------- 58 /** 59 * Function using for login validation 60 * validates username and password simultaneulsy 61 * if they passed previous distinct/individual validation 62 * 63 * @param string $username_login the username passed by previous validation 64 * @param string $password_login the password passed by previous validation 65 * @return boolean 66 */ 67 68 function login_check($username_login, $password_login) 69 { 70 //Use the input username and checks against 'users' table 71 $query = $this->CI->UserModel->getUserByUsername($username_login); 72 73 if (($query != null) && ($query->num_rows() == 0)) 74 { 75 //debugging 76 //echo '<br>username not found<br>'; 77 $username_cond = false; 78 } 79 else 80 { 81 //debugging 82 //echo '<br>username found<br>'; 83 $username_cond = true; 84 } 85 86 //debugging 87 //echo isset($password_login) ? '<br>password set<br>' : '<br>not set<br>'; 88 //echo $password_login; 89 90 if ($username_cond == true AND isset($password_login) AND $password_login!='') 91 { 92 //encrypts the random password using the md5 encryption 93 $encrypted_password = $this->CI->freakauth_light->_encode($password_login); 94 $query = $this->CI->UserModel->getUserForLogin($username_login , $encrypted_password); 95 96 if (($query != null) && ($query->num_rows() == 0)) 97 { 98 //we didn't find the password 99 $pass_cond = FALSE; 100 //debugging 101 //echo '<br>password not found<br>'; 102 } 103 else 104 { 105 //we found the password 106 $pass_cond = TRUE; 107 //debugging 108 //echo '<br>password found<br>'; 109 } 110 } 111 //username not found or password empty 112 else 113 { 114 $pass_cond = FALSE; 115 //debugging 116 //echo '<br>username not found or password empty<br>'; 117 } 118 119 //do we passed validation? 120 if ($username_cond == TRUE AND $pass_cond == TRUE) 121 { 122 return true; 123 } 124 else 125 { 126 //let's set the message 127 $this->login_error_message = $this->_error_prefix.$this->CI->lang->line('FAL_invalid_username_password_message').$this->_error_suffix; 128 return false; 129 } 130 } 131 132 // -------------------------------------------------------------------- 58 133 59 134 /** … … 96 171 /** 97 172 * RULES HELPER FUNCTION 98 * Password validation callback for login99 *100 * @access private101 * @param varchar $value102 * @return boolean103 */104 function password_login_check($value)105 {106 if (isset($this->username) AND $this->username!='')107 {108 //encrypts the random password using the md5 encryption109 $encrypted_password = $this->CI->freakauth_light->_encode($value);110 $query = $this->CI->UserModel->getUserForLogin($this->username , $encrypted_password);111 112 if (($query != null) && ($query->num_rows() == 0))113 {114 $this->set_message('password_login_check', $this->CI->lang->line('FAL_invalid_password_message'));115 return false;116 }117 else {return true;}118 }119 else120 {121 $this->set_message('password_login_check', $this->CI->lang->line('FAL_username_first_password_message'));122 return false;123 }124 125 }126 127 // --------------------------------------------------------------------128 129 /**130 * RULES HELPER FUNCTION131 173 * Password validation callback for change password 132 174 * … … 169 211 return $this->is_valid_text($callback, $value, $this->CI->config->item('FAL_user_name_min'), $this->CI->config->item('FAL_user_name_max')); 170 212 } 171 172 // --------------------------------------------------------------------173 174 /**175 * RULES HELPER FUNCTION176 * User name validation callback for login177 *178 * @access private179 * @param varchar $value180 * @return boolean181 */182 function username_login_check($value)183 {184 $this->username = $value;185 186 //Use the input username and checks against 'users' table187 $query = $this->CI->UserModel->getUserByUsername($value);188 189 if (($query != null) && ($query->num_rows() == 0))190 {191 $this->set_message('username_login_check', $this->CI->lang->line('FAL_invalid_username_message'));192 return false;193 }194 195 else {return true;}196 197 }198 199 200 213 201 214 // -------------------------------------------------------------------- FreakAuth/trunk/www/system/application/views/FreakAuth_light/content/login.php
r94 r111 1 1 <fieldset><legend accesskey="D" tabindex="1"><?=$heading?></legend> 2 <?=isset($this->fal_validation->login_error_message) ? $this->fal_validation->login_error_message : ''?> 2 3 <?=form_open('auth/')?> 3 4 <!--USERNAME--> … … 7 8 'maxlength'=>'30', 8 9 'size'=>'30', 9 'value'=> (isset($this->fal_validation) ? $this->fal_validation->{'user_name'} : '')))?>10 'value'=>''))?> 10 11 <?=(isset($this->fal_validation) ? $this->fal_validation->{'user_name'.'_error'} : '')?> 11 12 </p> … … 16 17 'maxlength'=>'30', 17 18 'size'=>'30', 18 'value'=> (isset($this->fal_validation) ? $this->fal_validation->{'password'} : '')))?>19 'value'=> ''))?> 19 20 20 21 <?=(isset($this->fal_validation) ? $this->fal_validation->{'password'.'_error'} : '')?> FreakAuth/trunk/www/system/language/english/freakauth_lang.php
r87 r111 90 90 //------------------------------------------------------------------ 91 91 $lang['FAL_invalid_user_message'] = 'Invalid user.'; 92 $lang['FAL_invalid_username_password_message'] = 'invalid username or password'; 92 93 $lang['FAL_invalid_username_message'] = 'Invalid username'; 93 94 $lang['FAL_invalid_password_message'] = 'Invalid password';
