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

Passed
Push — add-email-confirmation ( cd092b...fa3618 )
by Pedro
17:41
created

VerifyEmailController::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 6
c 1
b 0
f 1
nc 4
nop 0
dl 0
loc 11
rs 10
1
<?php
2
3
namespace Backpack\CRUD\app\Http\Controllers\Auth;
4
5
use Backpack\CRUD\app\Http\Requests\EmailVerificationRequest;
6
use Illuminate\Http\Request;
7
use Illuminate\Routing\Controller;
8
use Prologue\Alerts\Facades\Alert;
9
use Throwable;
10
use Exception;
11
12
class VerifyEmailController extends Controller
13
{
14
    public null|string $redirectTo = null;
15
16
    /**
17
     * Create a new controller instance.
18
     *
19
     * @return void
20
     */
21
    public function __construct()
22
    {
23
        $this->middleware(backpack_middleware());
24
25
        try {
26
            $signedMiddleware = new (app('router')->getMiddleware()['signed'])();
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected '(' on line 26 at column 36
Loading history...
27
        }catch(Throwable) {
28
            throw new Exception('Missing "signed" alias middleware in App/Http/Kernel.php. More info: https://backpackforlaravel.com/docs/6.x/base-how-to#enable-email-verification-in-backpack-routes');
29
        }
30
31
        $this->middleware($signedMiddleware)->only('verifyEmail');
32
        $this->middleware('throttle:'.config('backpack.base.email_verification_throttle_access'))->only('resendVerificationEmail');
33
34
        if (! backpack_users_have_email()) {
35
            abort(500, trans('backpack::base.no_email_column'));
36
        }
37
        // where to redirect after the email is verified
38
        $this->redirectTo = $this->redirectTo !== null ? $this->redirectTo : backpack_url('dashboard');
39
    }
40
41
    public function emailVerificationRequired(): \Illuminate\Contracts\View\View
42
    {
43
        return view(backpack_view('auth.verify-email'));
44
    }
45
46
    /**
47
     * Verify the user's email address.
48
     *
49
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
50
     */
51
    public function verifyEmail(EmailVerificationRequest $request)
52
    {
53
        $request->fulfill();
54
55
        return redirect($this->redirectTo);
56
    }
57
58
    /**
59
     * Resend the email verification notification.
60
     */
61
    public function resendVerificationEmail(Request $request): \Illuminate\Http\RedirectResponse
62
    {
63
        $request->user(backpack_guard_name())->sendEmailVerificationNotification();
64
65
        Alert::success('Email verification link sent successfully.')->flash();
66
67
        return back()->with('status', 'verification-link-sent');
68
    }
69
}
70