diff --git a/Modules/User/Guards/Sentinel.php b/Modules/User/Guards/Sentinel.php index 9ad02eb2f..10b968abb 100644 --- a/Modules/User/Guards/Sentinel.php +++ b/Modules/User/Guards/Sentinel.php @@ -80,8 +80,32 @@ public function login(Authenticatable $user) $this->setUser($user); } + /** + * @param array $credentials + * @param bool $remember + * @return bool + */ public function attempt(array $credentials, $remember = false) { return SentinelFacade::authenticate($credentials, $remember); } + + /** + * @return bool + */ + public function logout() + { + return SentinelFacade::logout(); + } + + /** + * @param int $userId + * @return bool + */ + public function loginUsingId($userId) + { + $impersonatedUser = app(\Modules\User\Repositories\UserRepository::class)->find($userId); + + return $this->login($impersonatedUser); + } } diff --git a/Modules/User/changelog.yml b/Modules/User/changelog.yml index c9e42cc5e..466d03df4 100644 --- a/Modules/User/changelog.yml +++ b/Modules/User/changelog.yml @@ -1,5 +1,8 @@ url: https://github.com/AsgardCms/Platform versions: + "2.x.x@unreleased": + added: + - New methods on the Sentinel Guard, logout and loginUsingId "2.5.0": added: - Trigger an event (UserIsUpdating) before a user is updated