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