Skip to content

Commit

Permalink
Use Hash::needsRehash in HasAttributes::castAttributeAsHashedString i…
Browse files Browse the repository at this point in the history
…nstead of Hash::isHashed
  • Loading branch information
bastien-phi committed Oct 17, 2023
1 parent 2f88a30 commit ce8e63e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ public static function encryptUsing($encrypter)
*/
protected function castAttributeAsHashedString($key, $value)
{
return $value !== null && ! Hash::isHashed($value) ? Hash::make($value) : $value;
return $value !== null && Hash::needsRehash($value) ? Hash::make($value) : $value;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Database/EloquentModelHashedCastingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ protected function defineDatabaseMigrationsAfterDatabaseRefreshed()

public function testHashed()
{
$this->hasher->expects('isHashed')
$this->hasher->expects('needsRehash')
->with('this is a password')
->andReturnFalse();
->andReturnTrue();

$this->hasher->expects('make')
->with('this is a password')
Expand All @@ -51,9 +51,9 @@ public function testHashed()

public function testNotHashedIfAlreadyHashed()
{
$this->hasher->expects('isHashed')
$this->hasher->expects('needsRehash')
->with('already-hashed-password')
->andReturnTrue();
->andReturnFalse();

$subject = HashedCast::create([
'password' => 'already-hashed-password',
Expand Down

0 comments on commit ce8e63e

Please sign in to comment.