Skip to content

Commit

Permalink
Merge pull request #647 from DirectoryTree/BUG-645
Browse files Browse the repository at this point in the history
Don't rehash passwords if password column is false
  • Loading branch information
stevebauman authored Apr 12, 2024
2 parents 42a3563 + b1ad38a commit 4c92ce8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Auth/DatabaseUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public function validateCredentials(Authenticatable $user, array $credentials):
*/
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void
{
$this->eloquent->rehashPasswordIfRequired($user, $credentials, $force);
if (($this->synchronizer->getConfig()['password_column'] ?? 'password') !== false) {
$this->eloquent->rehashPasswordIfRequired($user, $credentials, $force);
}
}
}
13 changes: 13 additions & 0 deletions tests/Feature/DatabaseUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,17 @@ public function test_failing_loudly_throws_exception_when_resolving_users()

$provider->retrieveByCredentials([]);
}

public function test_rehash_password_if_required_does_nothing_when_password_column_disabled()
{
$synchronizer = new UserSynchronizer(TestUserModelStub::class, [
'password_column' => false,
]);

$provider = $this->createDatabaseUserProvider(synchronizer: $synchronizer);

$provider->rehashPasswordIfRequired($model = new TestUserModelStub, ['password' => 'secret']);

$this->assertNull($model->password);
}
}

0 comments on commit 4c92ce8

Please sign in to comment.