Skip to content

Commit

Permalink
Adding logout and loginUsingId methods on the sentinal guard
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Aug 23, 2017
1 parent 5341a86 commit 7b87059
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Modules/User/Guards/Sentinel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
3 changes: 3 additions & 0 deletions Modules/User/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
url: https://github.com/AsgardCms/Platform
versions:
"2.x.x@unreleased":
added:
- New methods on the Sentinel Guard, <code>logout</code> and <code>loginUsingId</code>
"2.5.0":
added:
- Trigger an event (<code>UserIsUpdating</code>) before a user is updated
Expand Down

0 comments on commit 7b87059

Please sign in to comment.