Skip to content

Commit 1e61612

Browse files
committed
formatting
1 parent 7aabd8f commit 1e61612

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

src/Illuminate/Auth/SessionGuard.php

+21-20
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Illuminate\Support\Facades\Hash;
2121
use Illuminate\Support\Str;
2222
use Illuminate\Support\Traits\Macroable;
23+
use InvalidArgumentException;
2324
use RuntimeException;
2425
use Symfony\Component\HttpFoundation\Request;
2526
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
@@ -573,26 +574,6 @@ protected function cycleRememberToken(AuthenticatableContract $user)
573574
$this->provider->updateRememberToken($user, $token);
574575
}
575576

576-
/**
577-
* Rehash the current user's password.
578-
*
579-
* @param string $password
580-
* @param string $attribute
581-
* @return bool|null
582-
*
583-
* @throws \Illuminate\Auth\AuthenticationException
584-
*/
585-
protected function rehashUserPassword($password, $attribute)
586-
{
587-
if (! Hash::check($password, $this->user()->$attribute)) {
588-
throw new AuthenticationException('Password mismatch.');
589-
}
590-
591-
return tap($this->user()->forceFill([
592-
$attribute => Hash::make($password),
593-
]))->save();
594-
}
595-
596577
/**
597578
* Invalidate other sessions for the current user.
598579
*
@@ -622,6 +603,26 @@ public function logoutOtherDevices($password, $attribute = 'password')
622603
return $result;
623604
}
624605

606+
/**
607+
* Rehash the current user's password.
608+
*
609+
* @param string $password
610+
* @param string $attribute
611+
* @return bool|null
612+
*
613+
* @throws \InvalidArgumentException
614+
*/
615+
protected function rehashUserPassword($password, $attribute)
616+
{
617+
if (! Hash::check($password, $this->user()->{$attribute})) {
618+
throw new InvalidArgumentException("The given password does not match the current password.");
619+
}
620+
621+
return tap($this->user()->forceFill([
622+
$attribute => Hash::make($password),
623+
]))->save();
624+
}
625+
625626
/**
626627
* Register an authentication attempt event listener.
627628
*

tests/Integration/Auth/AuthenticationTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Illuminate\Tests\Integration\Auth;
44

5-
use Illuminate\Auth\AuthenticationException;
65
use Illuminate\Auth\EloquentUserProvider;
76
use Illuminate\Auth\Events\Attempting;
87
use Illuminate\Auth\Events\Authenticated;
@@ -20,6 +19,7 @@
2019
use Illuminate\Support\Str;
2120
use Illuminate\Support\Testing\Fakes\EventFake;
2221
use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser;
22+
use InvalidArgumentException;
2323
use Orchestra\Testbench\TestCase;
2424

2525
/**
@@ -225,8 +225,8 @@ public function testLoggingOutOtherDevices()
225225

226226
public function testPasswordMustBeValidToLogOutOtherDevices()
227227
{
228-
$this->expectException(AuthenticationException::class);
229-
$this->expectExceptionMessage('Password mismatch.');
228+
$this->expectException(InvalidArgumentException::class);
229+
$this->expectExceptionMessage('current password');
230230

231231
$this->app['auth']->loginUsingId(1);
232232

0 commit comments

Comments
 (0)