Skip to content

Commit

Permalink
logout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbadxiii committed May 16, 2022
1 parent 35090ae commit 6deda68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/Guards/SessionGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,20 @@ public function logout()
{
$user = $this->user();

if ($this->user && ($tokenRemember = $this->user->getRememberToken())) {
$tokenRemember->delete();
}
$recaller = $this->recaller();

$this->session->remove($this->getName());
if ($recaller !== null) {
$tokenRemember = $user->getRememberToken($recaller->token());

if ($tokenRemember) {
$tokenRemember->delete();
}

if (! is_null($this->recaller())) {
$this->cookies->get($this->getRememberName())->delete();
}

$this->session->remove($this->getName());

$this->event(new Logout($user));

$this->user = null;
Expand Down
11 changes: 7 additions & 4 deletions src/Middlewares/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
*/
class Authenticate extends Injectable implements AuthenticatesRequest
{
private const PROPERTY_AUTH_ACCESS = "authAccess";
private const PROPERTY_AUTH_ACCESS = "authAccess";
private const AUTH_ACCESS_BY_DEFAULT = true;

/**
* @var Dispatcher
Expand Down Expand Up @@ -60,8 +61,10 @@ protected function isGuest()
{
$controller = $this->dispatcher->getControllerClass();

return !(new $controller)->authAccess() ||
(property_exists($controller, self::PROPERTY_AUTH_ACCESS) &&
(new $controller)->authAccess === false);
$authAccess = property_exists($controller, self::PROPERTY_AUTH_ACCESS) ?
(new $controller)->authAccess : self::AUTH_ACCESS_BY_DEFAULT;

return (method_exists($controller, 'authAccess') &&
!(new $controller)->authAccess()) || $authAccess === false;
}
}

0 comments on commit 6deda68

Please sign in to comment.