Skip to content

Commit a6de7c6

Browse files
axlontaylorotwell
andauthored
[11.x] Rehash user passwords when logging in once (#50843)
* Rehash user passwords when validating credentials * Update SessionGuard.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent c8dfb41 commit a6de7c6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/Illuminate/Auth/SessionGuard.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ public function once(array $credentials = [])
253253
$this->fireAttemptEvent($credentials);
254254

255255
if ($this->validate($credentials)) {
256+
$this->rehashPasswordIfRequired($this->lastAttempted, $credentials);
257+
256258
$this->setUser($this->lastAttempted);
257259

258260
return true;

tests/Auth/AuthGuardTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ public function testLoginOnceSetsUser()
623623
});
624624
$guard->getProvider()->shouldReceive('retrieveByCredentials')->once()->with(['foo'])->andReturn($user);
625625
$guard->getProvider()->shouldReceive('validateCredentials')->once()->with($user, ['foo'])->andReturn(true);
626+
$guard->getProvider()->shouldReceive('rehashPasswordIfRequired')->with($user, ['foo'])->once();
626627
$guard->shouldReceive('setUser')->once()->with($user);
627628
$this->assertTrue($guard->once(['foo']));
628629
}
@@ -637,6 +638,7 @@ public function testLoginOnceFailure()
637638
});
638639
$guard->getProvider()->shouldReceive('retrieveByCredentials')->once()->with(['foo'])->andReturn($user);
639640
$guard->getProvider()->shouldReceive('validateCredentials')->once()->with($user, ['foo'])->andReturn(false);
641+
$guard->getProvider()->shouldNotReceive('rehashPasswordIfRequired');
640642
$this->assertFalse($guard->once(['foo']));
641643
}
642644

0 commit comments

Comments
 (0)