Completed
Push — master ( dfe268...3e25db )
by Brian
15s queued 12s
created

ConfirmablePasswordController::store()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 14
ccs 10
cts 10
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Modules\Sellers\Http\Controllers\Auth;
4
5
use App\Modules\Sellers\Http\Controllers\Controller;
6
use Illuminate\Http\RedirectResponse;
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\Auth;
9
use Illuminate\Validation\ValidationException;
10
use Illuminate\View\View;
11
12
class ConfirmablePasswordController extends Controller
13
{
14
    /**
15
     * Show the confirm password view.
16
     */
17 1
    public function show(): View
18
    {
19 1
        return view('seller.auth.confirm-password');
20
    }
21
22
    /**
23
     * Confirm the seller's password.
24
     */
25 2
    public function store(Request $request): RedirectResponse
26
    {
27 2
        if (! Auth::guard('seller')->validate([
28 2
            'email' => $request->user('seller')->email,
29 2
            'password' => $request->password,
30 2
        ])) {
31 1
            throw ValidationException::withMessages([
32 1
                'password' => __('auth.password'),
33 1
            ]);
34
        }
35
36 1
        $request->session()->put('seller.auth.password_confirmed_at', time());
37
38 1
        return redirect()->intended('/seller');
39
    }
40
}
41