diff --git a/src/Illuminate/Auth/Authenticatable.php b/src/Illuminate/Auth/Authenticatable.php index d7578a3dcb1e..c5c396eedeb3 100644 --- a/src/Illuminate/Auth/Authenticatable.php +++ b/src/Illuminate/Auth/Authenticatable.php @@ -2,6 +2,8 @@ namespace Illuminate\Auth; +use Illuminate\Support\Facades\Hash; + trait Authenticatable { /** @@ -11,6 +13,22 @@ 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. *