Passed
Push — master ( c12a7e...1e568f )
by Brian
02:51
created

ConfirmablePasswordController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 27
ccs 0
cts 12
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A show() 0 3 1
A store() 0 14 2
1
<?php
2
3
namespace App\Http\Controllers\Admin\Auth;
4
5
use App\Http\Controllers\Controller;
6
use App\Providers\RouteServiceProvider;
7
use Illuminate\Http\RedirectResponse;
8
use Illuminate\Http\Request;
9
use Illuminate\Support\Facades\Auth;
10
use Illuminate\Validation\ValidationException;
11
use Illuminate\View\View;
12
13
class ConfirmablePasswordController extends Controller
14
{
15
    /**
16
     * Show the confirm password view.
17
     */
18
    public function show(): View
19
    {
20
        return view('admin.auth.confirm-password');
21
    }
22
23
    /**
24
     * Confirm the admin's password.
25
     */
26
    public function store(Request $request): RedirectResponse
27
    {
28
        if (! Auth::guard('admin')->validate([
29
            'email' => $request->user('admin')->email,
30
            'password' => $request->password,
31
        ])) {
32
            throw ValidationException::withMessages([
33
                'password' => __('auth.password'),
34
            ]);
35
        }
36
37
        $request->session()->put('admin.auth.password_confirmed_at', time());
38
39
        return redirect()->intended(RouteServiceProvider::ADMIN_HOME);
40
    }
41
}
42