From 9c51e49a56ff15fc47ac1a6bf232c32c25d14fd0 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 28 Mar 2018 09:05:00 -0500 Subject: [PATCH] move method --- src/Illuminate/Auth/Authenticatable.php | 16 ---------------- src/Illuminate/Auth/SessionGuard.php | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/Illuminate/Auth/Authenticatable.php b/src/Illuminate/Auth/Authenticatable.php index c5c396eedeb3..a2d09a8d4dfd 100644 --- a/src/Illuminate/Auth/Authenticatable.php +++ b/src/Illuminate/Auth/Authenticatable.php @@ -13,22 +13,6 @@ trait Authenticatable */ protected $rememberTokenName = 'remember_token'; - /** - * Invalid other sessions for the current user. - * - * The application must be using the AuthenticateSession middleware. - * - * @param string $password - * @param string $attribute - * @return $this - */ - public function logoutOtherDevices($password, $attribute = 'password') - { - return tap($this->forceFill([ - $attribute => Hash::make($password) - ]))->save(); - } - /** * Get the name of the unique identifier for the user. * diff --git a/src/Illuminate/Auth/SessionGuard.php b/src/Illuminate/Auth/SessionGuard.php index 2e40c473dd13..7568a87001b8 100644 --- a/src/Illuminate/Auth/SessionGuard.php +++ b/src/Illuminate/Auth/SessionGuard.php @@ -4,6 +4,7 @@ use RuntimeException; use Illuminate\Support\Str; +use Illuminate\Support\Facades\Hash; use Illuminate\Support\Traits\Macroable; use Illuminate\Contracts\Session\Session; use Illuminate\Contracts\Auth\UserProvider; @@ -533,6 +534,26 @@ protected function cycleRememberToken(AuthenticatableContract $user) $this->provider->updateRememberToken($user, $token); } + /** + * Invalid other sessions for the current user. + * + * The application must be using the AuthenticateSession middleware. + * + * @param string $password + * @param string $attribute + * @return $this + */ + public function logoutOtherDevices($password, $attribute = 'password') + { + if (! $this->user()) { + return; + } + + return tap($this->user()->forceFill([ + $attribute => Hash::make($password) + ]))->save(); + } + /** * Register an authentication attempt event listener. *