Skip to content

Commit

Permalink
Merge pull request #220 from AfzalivE/master
Browse files Browse the repository at this point in the history
Passing non-existent credentials should return null user. Thanks @AfzalivE
  • Loading branch information
andrew13 committed Feb 18, 2014
2 parents 87f5b09 + 7b6fa97 commit 17ce63e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/Zizaco/Confide/Confide.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Zizaco/Confide/ConfideEloquentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public function getUserByIdentity( $credentials, $identityColumns = array('email
$user = $user->orWhere($attribute, $credentials[$attribute]);
}
}
else
{
return null;
}
}

$user = $user->get();
Expand Down
5 changes: 5 additions & 0 deletions tests/ConfideEloquentRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 0 additions & 7 deletions tests/ConfideTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 17ce63e

Please sign in to comment.