From f145deefbc315aaf833ed3d72bf8cab895996f69 Mon Sep 17 00:00:00 2001 From: Afzal Najam Date: Sat, 8 Feb 2014 16:49:33 -0500 Subject: [PATCH] Check for empty identity_columns after array_diff --- src/Zizaco/Confide/Confide.php | 4 ++++ tests/ConfideTest.php | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/Zizaco/Confide/Confide.php b/src/Zizaco/Confide/Confide.php index 1077296..06266d5 100644 --- a/src/Zizaco/Confide/Confide.php +++ b/src/Zizaco/Confide/Confide.php @@ -93,6 +93,10 @@ 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 228be54..0da54ee 100644 --- a/tests/ConfideTest.php +++ b/tests/ConfideTest.php @@ -114,6 +114,13 @@ 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()