Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Sep 20, 2018
1 parent 2260f65 commit 2e78bf4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 42 deletions.
10 changes: 2 additions & 8 deletions src/Illuminate/Auth/DatabaseUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,8 @@ protected function getGenericUser($user)
*/
public function validateCredentials(UserContract $user, array $credentials)
{
$hashed = $user->getAuthPassword();

if (strlen($hashed) === 0) {
return false;
}

return password_verify(
$credentials['password'], $hashed
return $this->hasher->check(
$credentials['password'], $user->getAuthPassword()
);
}
}
7 changes: 1 addition & 6 deletions src/Illuminate/Auth/EloquentUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,8 @@ public function retrieveByCredentials(array $credentials)
public function validateCredentials(UserContract $user, array $credentials)
{
$plain = $credentials['password'];
$hashed = $user->getAuthPassword();

if (strlen($hashed) === 0) {
return false;
}

return password_verify($plain, $hashed);
return $this->hasher->check($plain, $user->getAuthPassword());
}

/**
Expand Down
17 changes: 3 additions & 14 deletions tests/Auth/AuthDatabaseUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,11 @@ public function testCredentialValidation()
{
$conn = m::mock('Illuminate\Database\Connection');
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$hasher->shouldReceive('check')->once()->with('plain', 'hash')->andReturn(true);
$provider = new DatabaseUserProvider($conn, $hasher, 'foo');
$user = m::mock('Illuminate\Contracts\Auth\Authenticatable');
$user->shouldReceive('getAuthPassword')->once()->andReturn('$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm');
$result = $provider->validateCredentials($user, ['password' => 'secret']);

$this->assertTrue($result);
}

public function testCredentialValidationUsingUnknownAlgorithm()
{
$conn = m::mock('Illuminate\Database\Connection');
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$provider = new DatabaseUserProvider($conn, $hasher, 'foo');
$user = m::mock('Illuminate\Contracts\Auth\Authenticatable');
$user->shouldReceive('getAuthPassword')->once()->andReturn('$1$0590adc6$WVAjBIam8sJCgDieJGLey0');
$result = $provider->validateCredentials($user, ['password' => 's3cr3t']);
$user->shouldReceive('getAuthPassword')->once()->andReturn('hash');
$result = $provider->validateCredentials($user, ['password' => 'plain']);

$this->assertTrue($result);
}
Expand Down
17 changes: 3 additions & 14 deletions tests/Auth/AuthEloquentUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,11 @@ public function testCredentialValidation()
{
$conn = m::mock('Illuminate\Database\Connection');
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$hasher->shouldReceive('check')->once()->with('plain', 'hash')->andReturn(true);
$provider = new EloquentUserProvider($hasher, 'foo');
$user = m::mock('Illuminate\Contracts\Auth\Authenticatable');
$user->shouldReceive('getAuthPassword')->once()->andReturn('$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm');
$result = $provider->validateCredentials($user, ['password' => 'secret']);

$this->assertTrue($result);
}

public function testCredentialValidationUsingUnknownAlgorithm()
{
$conn = m::mock('Illuminate\Database\Connection');
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$provider = new EloquentUserProvider($hasher, 'foo');
$user = m::mock('Illuminate\Contracts\Auth\Authenticatable');
$user->shouldReceive('getAuthPassword')->once()->andReturn('$1$0590adc6$WVAjBIam8sJCgDieJGLey0');
$result = $provider->validateCredentials($user, ['password' => 's3cr3t']);
$user->shouldReceive('getAuthPassword')->once()->andReturn('hash');
$result = $provider->validateCredentials($user, ['password' => 'plain']);

$this->assertTrue($result);
}
Expand Down

0 comments on commit 2e78bf4

Please sign in to comment.