From c8c38b7fdbefe9f07628d76a58039c1642e43a68 Mon Sep 17 00:00:00 2001 From: Afzal Najam Date: Mon, 10 Feb 2014 19:33:21 -0500 Subject: [PATCH 1/2] Revert "Check for empty identity_columns after array_diff" This reverts commit f145deefbc315aaf833ed3d72bf8cab895996f69. --- src/Zizaco/Confide/Confide.php | 4 ---- tests/ConfideTest.php | 7 ------- 2 files changed, 11 deletions(-) diff --git a/src/Zizaco/Confide/Confide.php b/src/Zizaco/Confide/Confide.php index 06266d5..1077296 100644 --- a/src/Zizaco/Confide/Confide.php +++ b/src/Zizaco/Confide/Confide.php @@ -93,10 +93,6 @@ public function logAttempt( $credentials, $confirmed_only = false, $identity_col array_keys($credentials), array('password','remember') ); - // Recheck if identity_columns are populated now - if (empty($identity_columns)) { - return false; - } } // Check for throttle limit then log-in diff --git a/tests/ConfideTest.php b/tests/ConfideTest.php index 0da54ee..228be54 100644 --- a/tests/ConfideTest.php +++ b/tests/ConfideTest.php @@ -114,13 +114,6 @@ public function testShouldLogAttempt() $this->assertTrue( $this->confide->logAttempt( $credentials, true ) ); - - unset($credentials['username']); - unset($credentials['email']); - // Should not login because there is no username or email provided - $this->assertFalse( - $this->confide->logAttempt( $credentials, true ) - ); } public function testShouldThrottleLogAttempt() From 7b6fa97b4b12c0de26392a99492da809bfe55289 Mon Sep 17 00:00:00 2001 From: Afzal Najam Date: Mon, 10 Feb 2014 19:41:04 -0500 Subject: [PATCH 2/2] Passing nonexistent credentials should return null Fixed #215 --- src/Zizaco/Confide/ConfideEloquentRepository.php | 4 ++++ tests/ConfideEloquentRepositoryTest.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/Zizaco/Confide/ConfideEloquentRepository.php b/src/Zizaco/Confide/ConfideEloquentRepository.php index 24a3b8a..982b43c 100644 --- a/src/Zizaco/Confide/ConfideEloquentRepository.php +++ b/src/Zizaco/Confide/ConfideEloquentRepository.php @@ -122,6 +122,10 @@ public function getUserByIdentity( $credentials, $identityColumns = array('email $user = $user->orWhere($attribute, $credentials[$attribute]); } } + else + { + return null; + } } $user = $user->get(); diff --git a/tests/ConfideEloquentRepositoryTest.php b/tests/ConfideEloquentRepositoryTest.php index 50e1329..9de14d2 100644 --- a/tests/ConfideEloquentRepositoryTest.php +++ b/tests/ConfideEloquentRepositoryTest.php @@ -162,6 +162,11 @@ public function testShouldGetByIdentity() $this->assertEquals( null, $this->repo->getUserByIdentity( array() ) ); + + // When passing credentials that don't exist should return null + $this->assertEquals( + null, $this->repo->getUserByIdentity( array('token' => 'random-token-value') ) + ); } public function testShouldGetPasswordRemindersCountByToken()