Skip to content

Commit

Permalink
move method
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 28, 2018
1 parent 0d3cb33 commit 9c51e49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/Illuminate/Auth/Authenticatable.php
Expand Up @@ -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.
*
Expand Down
21 changes: 21 additions & 0 deletions src/Illuminate/Auth/SessionGuard.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 9c51e49

Please sign in to comment.