-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.8] Send LogoutOtherDevices event when request is made. #27865
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Illuminate\Auth\Events; | ||
|
||
use Illuminate\Queue\SerializesModels; | ||
|
||
class LogoutOtherDevices | ||
{ | ||
use SerializesModels; | ||
|
||
/** | ||
* The authentication guard name. | ||
* | ||
* @var string | ||
*/ | ||
public $guard; | ||
|
||
/** | ||
* The authenticated user. | ||
* | ||
* @var \Illuminate\Contracts\Auth\Authenticatable | ||
*/ | ||
public $user; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @param string $guard | ||
* @param \Illuminate\Contracts\Auth\Authenticatable $user | ||
* @return void | ||
*/ | ||
public function __construct($guard, $user) | ||
{ | ||
$this->user = $user; | ||
$this->guard = $guard; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -552,6 +552,8 @@ public function logoutOtherDevices($password, $attribute = 'password') | |
|
||
$this->queueRecallerCookie($this->user()); | ||
|
||
$this->fireLogoutOtherDevicesEvent($this->user()); | ||
|
||
return $result; | ||
} | ||
|
||
|
@@ -615,6 +617,21 @@ protected function fireAuthenticatedEvent($user) | |
} | ||
} | ||
|
||
/** | ||
* Fire the logout other devices event if the dispatcher is set. | ||
* | ||
* @param \Illuminate\Contracts\Auth\Authenticatable $user | ||
* @return void | ||
*/ | ||
protected function fireLogoutOtherDevicesEvent($user) | ||
{ | ||
if (isset($this->events)) { | ||
$this->events->dispatch(new Events\LogoutOtherDevices( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the namespace be imported at the top - then just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just following the other existing |
||
$this->name, $user | ||
)); | ||
} | ||
} | ||
|
||
/** | ||
* Fire the failed authentication attempt event with the given arguments. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason that the user parameter here and in the
fireLogoutOtherDevicesEvent
method isn't actually typehinted?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the existing Auth event has a type-hint. If you want that feel free to make a different PR to suggest those changes. I don't want to bloat this PR to add huge changes just to be rejected.