@@ -298,46 +298,48 @@ public function login($identifier, $pass, $remember = false, $totp_code = null)
298298 $ row = $ query ->row ();
299299
300300 // if email and pass matches and not banned
301- $ password = ($ this ->config_vars ['use_password_hash ' ] ? $ pass : $ this ->hash_password ($ pass , $ row ->id ));
302301
303- if ( $ query ->num_rows () != 0 && $ this ->verify_password ($ password , $ row ->pass ) ) {
304-
305- // If email and pass matches
306- // create session
307- $ data = array (
308- 'id ' => $ row ->id ,
309- 'username ' => $ row ->username ,
310- 'email ' => $ row ->email ,
311- 'loggedin ' => true
312- );
302+ if ($ query ->num_rows () != 0 ) {
303+ $ password = ($ this ->config_vars ['use_password_hash ' ] ? $ pass : $ this ->hash_password ($ pass , $ row ->id ));
304+
305+ if ($ this ->verify_password ($ password , $ row ->pass )) {
306+ // If email and pass matches
307+ // create session
308+ $ data = array (
309+ 'id ' => $ row ->id ,
310+ 'username ' => $ row ->username ,
311+ 'email ' => $ row ->email ,
312+ 'loggedin ' => true
313+ );
313314
314- $ this ->CI ->session ->set_userdata ($ data );
315+ $ this ->CI ->session ->set_userdata ($ data );
316+
317+ if ($ remember ){
318+ $ this ->CI ->load ->helper ('string ' );
319+ $ expire = $ this ->config_vars ['remember ' ];
320+ $ today = date ("Y-m-d " );
321+ $ remember_date = date ("Y-m-d " , strtotime ($ today . $ expire ) );
322+ $ random_string = random_string ('alnum ' , 16 );
323+ $ this ->update_remember ($ row ->id , $ random_string , $ remember_date );
324+ $ cookie = array (
325+ 'name ' => 'user ' ,
326+ 'value ' => $ row ->id . "- " . $ random_string ,
327+ 'expire ' => 99 *999 *999 ,
328+ 'path ' => '/ ' ,
329+ );
330+ $ this ->CI ->input ->set_cookie ($ cookie );
331+ }
315332
316- if ( $ remember ){
317- $ this ->CI ->load ->helper ('string ' );
318- $ expire = $ this ->config_vars ['remember ' ];
319- $ today = date ("Y-m-d " );
320- $ remember_date = date ("Y-m-d " , strtotime ($ today . $ expire ) );
321- $ random_string = random_string ('alnum ' , 16 );
322- $ this ->update_remember ($ row ->id , $ random_string , $ remember_date );
323- $ cookie = array (
324- 'name ' => 'user ' ,
325- 'value ' => $ row ->id . "- " . $ random_string ,
326- 'expire ' => 99 *999 *999 ,
327- 'path ' => '/ ' ,
328- );
329- $ this ->CI ->input ->set_cookie ($ cookie );
330- }
333+ // update last login
334+ $ this ->update_last_login ($ row ->id );
335+ $ this ->update_activity ();
331336
332- // update last login
333- $ this ->update_last_login ( $ row -> id );
334- $ this -> update_activity ();
337+ if ( $ this -> config_vars [ ' remove_successful_attempts ' ] == true ){
338+ $ this ->reset_login_attempts ( );
339+ }
335340
336- if ($ this ->config_vars ['remove_successful_attempts ' ] == true ){
337- $ this ->reset_login_attempts ();
341+ return true ;
338342 }
339-
340- return true ;
341343 }
342344 // if not matches
343345 else {
0 commit comments