1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Microboard\Http\Controllers\Auth; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Auth\VerifiesEmails; |
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use Illuminate\Http\Response; |
8
|
|
|
use Microboard\Http\Controllers\Controller; |
9
|
|
|
|
10
|
|
|
class VerificationController extends Controller |
11
|
|
|
{ |
12
|
|
|
/* |
13
|
|
|
|-------------------------------------------------------------------------- |
14
|
|
|
| Email Verification Controller |
15
|
|
|
|-------------------------------------------------------------------------- |
16
|
|
|
| |
17
|
|
|
| This controller is responsible for handling email verification for any |
18
|
|
|
| user that recently registered with the application. Emails may also |
19
|
|
|
| be re-sent if the user didn't receive the original email message. |
20
|
|
|
| |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
use VerifiesEmails; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Where to redirect users when the intended url fails. |
27
|
|
|
*/ |
28
|
|
|
protected function redirectTo() |
29
|
|
|
{ |
30
|
|
|
return url(config('microboard.routes.prefix')); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Create a new controller instance. |
35
|
|
|
* |
36
|
|
|
* @return void |
|
|
|
|
37
|
|
|
*/ |
38
|
|
|
public function __construct() |
39
|
|
|
{ |
40
|
|
|
$this->middleware('auth'); |
41
|
|
|
$this->middleware('signed')->only('verify'); |
42
|
|
|
$this->middleware('throttle:6,1')->only('verify', 'resend'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Show the email verification notice. |
47
|
|
|
* |
48
|
|
|
* @param \Illuminate\Http\Request $request |
49
|
|
|
* @return \Illuminate\Http\Response|\Illuminate\View\View |
50
|
|
|
*/ |
51
|
|
|
public function show(Request $request) |
52
|
|
|
{ |
53
|
|
|
return $request->user()->hasVerifiedEmail() |
54
|
|
|
? redirect($this->redirectPath()) |
55
|
|
|
: view('microboard::auth.verify'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Resend the email verification notification. |
60
|
|
|
* |
61
|
|
|
* @param \Illuminate\Http\Request $request |
62
|
|
|
* @return \Illuminate\Http\RedirectResponse|Response |
63
|
|
|
*/ |
64
|
|
|
public function resend(Request $request) |
65
|
|
|
{ |
66
|
|
|
if ($request->user()->hasVerifiedEmail()) { |
67
|
|
|
return $request->wantsJson() |
68
|
|
|
? new Response('', 204) |
69
|
|
|
: redirect($this->redirectPath()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$request->user()->sendEmailVerificationNotification(); |
73
|
|
|
|
74
|
|
|
return $request->wantsJson() |
75
|
|
|
? new Response('', 202) |
76
|
|
|
: back()->with('alert', [ |
77
|
|
|
'text' => trans('microboard::pages.verify.resend'), |
78
|
|
|
'type' => 'success' |
79
|
|
|
]); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.