Skip to content

Commit 6deda68

Browse files
committed
logout fix
1 parent 35090ae commit 6deda68

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/Guards/SessionGuard.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,20 @@ public function logout()
202202
{
203203
$user = $this->user();
204204

205-
if ($this->user && ($tokenRemember = $this->user->getRememberToken())) {
206-
$tokenRemember->delete();
207-
}
205+
$recaller = $this->recaller();
208206

209-
$this->session->remove($this->getName());
207+
if ($recaller !== null) {
208+
$tokenRemember = $user->getRememberToken($recaller->token());
209+
210+
if ($tokenRemember) {
211+
$tokenRemember->delete();
212+
}
210213

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

217+
$this->session->remove($this->getName());
218+
215219
$this->event(new Logout($user));
216220

217221
$this->user = null;

src/Middlewares/Authenticate.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
*/
1212
class Authenticate extends Injectable implements AuthenticatesRequest
1313
{
14-
private const PROPERTY_AUTH_ACCESS = "authAccess";
14+
private const PROPERTY_AUTH_ACCESS = "authAccess";
15+
private const AUTH_ACCESS_BY_DEFAULT = true;
1516

1617
/**
1718
* @var Dispatcher
@@ -60,8 +61,10 @@ protected function isGuest()
6061
{
6162
$controller = $this->dispatcher->getControllerClass();
6263

63-
return !(new $controller)->authAccess() ||
64-
(property_exists($controller, self::PROPERTY_AUTH_ACCESS) &&
65-
(new $controller)->authAccess === false);
64+
$authAccess = property_exists($controller, self::PROPERTY_AUTH_ACCESS) ?
65+
(new $controller)->authAccess : self::AUTH_ACCESS_BY_DEFAULT;
66+
67+
return (method_exists($controller, 'authAccess') &&
68+
!(new $controller)->authAccess()) || $authAccess === false;
6669
}
6770
}

0 commit comments

Comments
 (0)