Completed
Push — master ( 2fdbfa...640218 )
by Ivan
01:49
created

StageFrontController::disableLaravelDebugbar()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
crap 6
1
<?php
2
3
namespace CodeZero\StageFront\Controllers;
4
5
use CodeZero\StageFront\Rules\LoginAndPasswordMatch;
6
use Illuminate\Routing\Controller;
7
8
class StageFrontController extends Controller
9
{
10
    /**
11
     * Show the StageFront login screen.
12
     *
13
     * @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse
14
     */
15 1
    public function create()
16
    {
17 1
        if (session('stagefront.unlocked') === true) {
18 1
            return redirect('/');
19
        }
20
21
        $liveSite = config('stagefront.live_site');
22
23
        if ($liveSite) {
24
            $liveSite = [
25
                'url' => $liveSite,
26
                'host' => parse_url($liveSite, PHP_URL_HOST),
27
            ];
28
        }
29
30
        return view('stagefront::login', compact('liveSite'));
31
    }
32
33
    /**
34
     * Attempt to log a user in to StageFront.
35
     *
36
     * @return \Illuminate\Http\RedirectResponse
37
     */
38 8
    public function store()
39
    {
40 8
        request()->validate([
41 8
            'login' => ['required'],
42 8
            'password' => ['required', new LoginAndPasswordMatch()],
43
        ], [
44 8
            'login.required' => trans('stagefront::errors.login.required'),
45 8
            'password.required' => trans('stagefront::errors.password.required'),
46
        ]);
47
48 5
        session()->put('stagefront.unlocked', true);
49
50 5
        return redirect()->intended('/');
51
    }
52
}
53