Passed
Push — master ( c12a7e...1e568f )
by Brian
02:51
created

EmailVerificationRequest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 55
ccs 0
cts 16
cp 0
rs 10
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 3 1
A fulfill() 0 6 2
A authorize() 0 11 3
A withValidator() 0 3 1
1
<?php
2
3
namespace App\Http\Requests\Admin\Auth;
4
5
use Illuminate\Auth\Events\Verified;
6
use Illuminate\Foundation\Http\FormRequest;
7
use Illuminate\Validation\Validator;
8
9
/**
10
 * @see \Illuminate\Foundation\Auth\EmailVerificationRequest
11
 */
12
class EmailVerificationRequest extends FormRequest
13
{
14
    /**
15
     * Determine if the user is authorized to make this request.
16
     *
17
     * @return bool
18
     */
19
    public function authorize()
20
    {
21
        if (! hash_equals((string) $this->user('admin')->getKey(), (string) $this->route('id'))) {
22
            return false;
23
        }
24
25
        if (! hash_equals(sha1($this->user('admin')->getEmailForVerification()), (string) $this->route('hash'))) {
26
            return false;
27
        }
28
29
        return true;
30
    }
31
32
    /**
33
     * Get the validation rules that apply to the request.
34
     *
35
     * @return array
36
     */
37
    public function rules()
38
    {
39
        return [
40
            //
41
        ];
42
    }
43
44
    /**
45
     * Fulfill the email verification request.
46
     *
47
     * @return void
48
     */
49
    public function fulfill()
50
    {
51
        if (! $this->user('admin')->hasVerifiedEmail()) {
52
            $this->user('admin')->markEmailAsVerified();
53
54
            event(new Verified($this->user('admin')));
55
        }
56
    }
57
58
    /**
59
     * Configure the validator instance.
60
     *
61
     * @param  \Illuminate\Validation\Validator  $validator
62
     * @return void
63
     */
64
    public function withValidator(Validator $validator)
65
    {
66
        return $validator;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $validator returns the type Illuminate\Validation\Validator which is incompatible with the documented return type void.
Loading history...
67
    }
68
}
69