LoginController::logout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Oscer\Cms\Backend\Http\Controllers\Auth;
4
5
use Illuminate\Contracts\Auth\StatefulGuard;
6
use Illuminate\Http\RedirectResponse;
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\Auth;
9
use Illuminate\Validation\ValidationException;
10
use Oscer\Cms\Backend\Http\Requests\Auth\LoginRequest;
11
12
class LoginController
13
{
14
    public function showLoginForm()
15
    {
16
        return view('cms::auth.login');
17
    }
18
19
    public function login(LoginRequest $request)
20
    {
21
        if ($this->guard()->attempt($request->validated(), $request->filled('remember'))) {
22
            $request->session()->regenerate();
0 ignored issues
show
Bug introduced by
The method regenerate() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
24
            return redirect()->route('cms.backend.start');
25
        }
26
27
        throw ValidationException::withMessages([
28
            'email' => [trans('auth.failed')],
29
        ]);
30
    }
31
32
    public function logout(Request $request): RedirectResponse
33
    {
34
        $this->guard()->logout();
35
36
        $request->session()->invalidate();
37
38
        return redirect()->route('cms.auth.login')->with('loggedOut', true);
39
    }
40
41
    protected function guard(): StatefulGuard
42
    {
43
        return Auth::guard('web');
44
    }
45
}
46