Skip to content

Commit

Permalink
Fixing some bugs with credential constraining.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 30, 2012
1 parent 7d7db8c commit a3f7350
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/DatabaseUserProvider.php
Expand Up @@ -72,7 +72,7 @@ public function retrieveByCredentials(array $credentials)

foreach ($credentials as $key => $value)
{
$query->where($key, $value);
if ( ! str_contains($key, 'password')) $query->where($key, $value);
}

// Now we are ready to execute the query to see if we have an user matching
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/EloquentUserProvider.php
Expand Up @@ -57,7 +57,7 @@ public function retrieveByCredentials(array $credentials)

foreach ($credentials as $key => $value)
{
$query->where($key, $value);
if ( ! str_contains($key, 'password')) $query->where($key, $value);
}

return $query->first();
Expand Down
2 changes: 1 addition & 1 deletion tests/DatabaseUserProviderTest.php
Expand Up @@ -46,7 +46,7 @@ public function testRetrieveByCredentialsReturnsUserWhenUserIsFound()
$conn->shouldReceive('first')->once()->andReturn(array('id' => 1, 'name' => 'taylor'));
$hasher = m::mock('Illuminate\Hashing\HasherInterface');
$provider = new Illuminate\Auth\DatabaseUserProvider($conn, $hasher, 'foo');
$user = $provider->retrieveByCredentials(array('username' => 'dayle'));
$user = $provider->retrieveByCredentials(array('username' => 'dayle', 'password' => 'foo'));

$this->assertInstanceOf('Illuminate\Auth\GenericUser', $user);
$this->assertEquals(1, $user->getIdentifier());
Expand Down
2 changes: 1 addition & 1 deletion tests/EloquentUserProviderTest.php
Expand Up @@ -31,7 +31,7 @@ public function testRetrieveByCredentialsReturnsUser()
$mock->shouldReceive('where')->once()->with('username', 'dayle');
$mock->shouldReceive('first')->once()->andReturn('bar');
$provider->expects($this->once())->method('createModel')->will($this->returnValue($mock));
$user = $provider->retrieveByCredentials(array('username' => 'dayle'));
$user = $provider->retrieveByCredentials(array('username' => 'dayle', 'password' => 'foo'));

$this->assertEquals('bar', $user);
}
Expand Down

0 comments on commit a3f7350

Please sign in to comment.