LoginJob::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 7
rs 9.4286
c 2
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php namespace Cerbero\Auth\Jobs;
2
3
use Cerbero\Auth\Exceptions\DisplayException;
4
use Illuminate\Contracts\Auth\Guard;
5
use Illuminate\Contracts\Bus\SelfHandling;
6
7
class LoginJob implements SelfHandling {
8
9
	/**
10
	 * @author	Andrea Marco Sartori
11
	 * @var		array	$credentials	Credentials.
12
	 */
13
	public $credentials;
14
15
	/**
16
	 * @author	Andrea Marco Sartori
17
	 * @var		boolean	$remember	Whether to remember the session.
18
	 */
19
	public $remember;
20
21
	/**
22
	 * Create a new job instance.
23
	 *
24
	 * @return void
25
	 */
26
	public function __construct()
27
	{
28
		$this->credentials = app('request')->only(config('_auth.login.fields'));
29
30
		$this->remember = app('request')->get(config('_auth.login.remember_me'), false);
31
	}
32
33
	/**
34
	 * Execute the job.
35
	 *
36
	 * @return void
37
	 */
38
	public function handle(Guard $auth)
39
	{
40
		if( ! $auth->attempt($this->credentials, $this->remember))
41
		{
42
			throw new DisplayException('auth::login.error');
43
		}
44
	}
45
46
}
47