Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 6a87fb...a42a1b )
by Cristian
15:19 queued 07:45
created

VerifiesEmails::verify()   B

Complexity

Conditions 8
Paths 10

Size

Total Lines 28

Duplication

Lines 5
Ratio 17.86 %

Importance

Changes 0
Metric Value
cc 8
nc 10
nop 1
dl 5
loc 28
rs 8.4444
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Auth;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Illuminate\Auth\Events\Verified;
7
use Illuminate\Http\Request;
8
use Illuminate\Http\Response;
9
10
trait VerifiesEmails
11
{
12
    use RedirectsUsers;
13
14
    /**
15
     * Show the email verification notice.
16
     *
17
     * @param  \Illuminate\Http\Request  $request
18
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...e\Http\RedirectResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
19
     */
20
    public function show(Request $request)
21
    {
22
        return $request->user()->hasVerifiedEmail()
23
                        ? redirect($this->redirectPath())
24
                        : view('auth.verify');
25
    }
26
27
    /**
28
     * Mark the authenticated user's email address as verified.
29
     *
30
     * @param  \Illuminate\Http\Request  $request
31
     * @return \Illuminate\Http\Response
32
     *
33
     * @throws \Illuminate\Auth\Access\AuthorizationException
34
     */
35
    public function verify(Request $request)
36
    {
37
        if (! hash_equals((string) $request->route('id'), (string) $request->user()->getKey())) {
38
            throw new AuthorizationException;
39
        }
40
41
        if (! hash_equals((string) $request->route('hash'), sha1($request->user()->getEmailForVerification()))) {
42
            throw new AuthorizationException;
43
        }
44
45 View Code Duplication
        if ($request->user()->hasVerifiedEmail()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
            return $request->wantsJson()
47
                        ? new Response('', 204)
48
                        : redirect($this->redirectPath());
49
        }
50
51
        if ($request->user()->markEmailAsVerified()) {
52
            event(new Verified($request->user()));
53
        }
54
55
        if ($response = $this->verified($request)) {
56
            return $response;
57
        }
58
59
        return $request->wantsJson()
60
                    ? new Response('', 204)
61
                    : redirect($this->redirectPath())->with('verified', true);
62
    }
63
64
    /**
65
     * The user has been verified.
66
     *
67
     * @param  \Illuminate\Http\Request  $request
68
     * @return mixed
69
     */
70
    protected function verified(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
    {
72
        //
73
    }
74
75
    /**
76
     * Resend the email verification notification.
77
     *
78
     * @param  \Illuminate\Http\Request  $request
79
     * @return \Illuminate\Http\Response
80
     */
81
    public function resend(Request $request)
82
    {
83 View Code Duplication
        if ($request->user()->hasVerifiedEmail()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
84
            return $request->wantsJson()
85
                        ? new Response('', 204)
86
                        : redirect($this->redirectPath());
87
        }
88
89
        $request->user()->sendEmailVerificationNotification();
90
91
        return $request->wantsJson()
92
                    ? new Response('', 202)
93
                    : back()->with('resent', true);
94
    }
95
}
96