-
Notifications
You must be signed in to change notification settings - Fork 42
/
LoginAction.php
53 lines (39 loc) · 1.01 KB
/
LoginAction.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
<?php
namespace MagicLink\Actions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Facades\Auth;
class LoginAction extends ResponseAction
{
protected $authIdentifier;
protected $guard;
protected bool $remember = false;
/**
* Constructor to action.
*
* @param mixed $httpResponse
*/
public function __construct(Authenticatable $user, $httpResponse = null, ?string $guard = null)
{
$this->authIdentifier = $user->getAuthIdentifier();
$this->response($httpResponse);
$this->guard = $guard;
}
public function remember(bool $remember = true): self
{
$this->remember = $remember;
return $this;
}
public function guard(string $guard): self
{
$this->guard = $guard;
return $this;
}
/**
* Execute Action.
*/
public function run()
{
Auth::guard($this->guard)->loginUsingId($this->authIdentifier, $this->remember);
return parent::run();
}
}