TwoFactorController::showOtpForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Thinkstudeo\Rakshak\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Support\Carbon;
7
8
class TwoFactorController extends Controller
9
{
10
    /**
11
     * Show the form to confirm the otp.
12
     *
13
     * @return View
0 ignored issues
show
Bug introduced by
The type Thinkstudeo\Rakshak\Http\Controllers\View was not found. Did you mean View? If so, make sure to prefix the type with \.
Loading history...
14
     */
15
    public function showOtpForm()
16
    {
17
        return view('rakshak::otp.verify');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('rakshak::otp.verify') returns the type Illuminate\View\View which is incompatible with the documented return type Thinkstudeo\Rakshak\Http\Controllers\View.
Loading history...
18
    }
19
20
    /**
21
     * Verify the otp entered by the user with the value from the database.
22
     * When verified redirect the user to the intended page.
23
     *
24
     * @param Request $request
25
     * @return void
26
     */
27
    public function verifyOtp(Request $request)
28
    {
29
        $request->validate(['otp' => 'required']);
30
        $user = auth()->user();
31
        if ($request->otp === $user->otp_token) {
32
            $user->otp_expiry = Carbon::now()->addMinutes(config('session.lifetime'));
33
            $user->save();
34
35
            return redirect($request->session()->previousUrl());
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect($request...ssion()->previousUrl()) returns the type Illuminate\Http\Redirect...nate\Routing\Redirector which is incompatible with the documented return type void.
Loading history...
36
        }
37
    }
38
}
39