Completed
Push — master ( 41a1c8...e65970 )
by Mohamed
03:30 queued 15s
created

VerificationController   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 6
dl 0
loc 72
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A redirectTo() 0 4 1
A __construct() 0 6 1
A show() 0 6 2
A resend() 0 17 4
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
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

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.

Loading history...
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