-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathSessionGuard.php
57 lines (47 loc) · 1.38 KB
/
SessionGuard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace PHPPM\Laravel;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Foundation\Application;
use Symfony\Component\HttpFoundation\Request;
use Illuminate\Contracts\Session\Session;
class SessionGuard extends \Illuminate\Auth\SessionGuard
{
protected Application $app;
public function __construct(
public readonly string $name,
UserProvider $provider,
Session $session,
Request $request = null,
Application $app
) {
$this->session = $session;
$this->request = $request;
$this->provider = $provider;
$this->app = $app;
}
public function setRequest(Request $request): self
{
// reset the current state
$this->reset();
// retrieve a new session from the app
$this->session = $this->app->make('session');
return parent::setRequest($request);
}
public function getName(): string
{
return 'login_'.$this->name.'_'.sha1(parent::class);
}
public function getRecallerName(): string
{
return 'remember_'.$this->name.'_'.sha1(parent::class);
}
protected function reset(): void
{
$this->user = null;
$this->lastAttempted = null;
$this->viaRemember = false;
$this->loggedOut = false;
$this->tokenRetrievalAttempted = false;
$this->recallAttempted = false;
}
}