Skip to content

Commit 9c51e49

Browse files
committed
move method
1 parent 0d3cb33 commit 9c51e49

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

src/Illuminate/Auth/Authenticatable.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,6 @@ trait Authenticatable
1313
*/
1414
protected $rememberTokenName = 'remember_token';
1515

16-
/**
17-
* Invalid other sessions for the current user.
18-
*
19-
* The application must be using the AuthenticateSession middleware.
20-
*
21-
* @param string $password
22-
* @param string $attribute
23-
* @return $this
24-
*/
25-
public function logoutOtherDevices($password, $attribute = 'password')
26-
{
27-
return tap($this->forceFill([
28-
$attribute => Hash::make($password)
29-
]))->save();
30-
}
31-
3216
/**
3317
* Get the name of the unique identifier for the user.
3418
*

src/Illuminate/Auth/SessionGuard.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use RuntimeException;
66
use Illuminate\Support\Str;
7+
use Illuminate\Support\Facades\Hash;
78
use Illuminate\Support\Traits\Macroable;
89
use Illuminate\Contracts\Session\Session;
910
use Illuminate\Contracts\Auth\UserProvider;
@@ -533,6 +534,26 @@ protected function cycleRememberToken(AuthenticatableContract $user)
533534
$this->provider->updateRememberToken($user, $token);
534535
}
535536

537+
/**
538+
* Invalid other sessions for the current user.
539+
*
540+
* The application must be using the AuthenticateSession middleware.
541+
*
542+
* @param string $password
543+
* @param string $attribute
544+
* @return $this
545+
*/
546+
public function logoutOtherDevices($password, $attribute = 'password')
547+
{
548+
if (! $this->user()) {
549+
return;
550+
}
551+
552+
return tap($this->user()->forceFill([
553+
$attribute => Hash::make($password)
554+
]))->save();
555+
}
556+
536557
/**
537558
* Register an authentication attempt event listener.
538559
*

0 commit comments

Comments
 (0)