|
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
|
|
|
|
|
10
|
|
|
class VerifyEmailController extends Controller |
|
11
|
|
|
{ |
|
12
|
|
|
public null|string $redirectTo = null; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Create a new controller instance. |
|
16
|
|
|
* |
|
17
|
|
|
* @return void |
|
18
|
|
|
*/ |
|
19
|
|
|
public function __construct() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->middleware(backpack_middleware()); |
|
22
|
|
|
$this->middleware('signed')->only('verifyEmail'); |
|
23
|
|
|
$this->middleware('throttle:'.config('backpack.base.email_verification_throttle_access'))->only('resendVerificationEmail'); |
|
24
|
|
|
|
|
25
|
|
|
if (! backpack_users_have_email()) { |
|
26
|
|
|
abort(500, trans('backpack::base.no_email_column')); |
|
27
|
|
|
} |
|
28
|
|
|
// where to redirect after the email is verified |
|
29
|
|
|
$this->redirectTo = $this->redirectTo !== null ? $this->redirectTo : backpack_url('dashboard'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function emailVerificationRequired(): \Illuminate\Contracts\View\View |
|
33
|
|
|
{ |
|
34
|
|
|
return view(backpack_view('auth.verify-email')); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Verify the user's email address. |
|
39
|
|
|
* |
|
40
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
|
41
|
|
|
*/ |
|
42
|
|
|
public function verifyEmail(EmailVerificationRequest $request) |
|
43
|
|
|
{ |
|
44
|
|
|
$request->fulfill(); |
|
45
|
|
|
|
|
46
|
|
|
return redirect($this->redirectTo); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Resend the email verification notification. |
|
51
|
|
|
*/ |
|
52
|
|
|
public function resendVerificationEmail(Request $request): \Illuminate\Http\RedirectResponse |
|
53
|
|
|
{ |
|
54
|
|
|
$request->user(backpack_guard_name())->sendEmailVerificationNotification(); |
|
55
|
|
|
|
|
56
|
|
|
Alert::success('Email verification link sent successfully.')->flash(); |
|
57
|
|
|
|
|
58
|
|
|
return back()->with('status', 'verification-link-sent'); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|