We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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
|
|||
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
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
|
|||
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
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 |
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.