AuthenticatedSessionController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 5 1
A store() 0 7 1
A destroy() 0 9 1
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use App\Http\Requests\Auth\LoginRequest;
7
use Illuminate\Http\RedirectResponse;
8
use Illuminate\Http\Request;
9
use Illuminate\Support\Facades\Auth;
10
use Illuminate\Support\Facades\Route;
11
use Inertia\Inertia;
12
use Inertia\Response;
13
14
class AuthenticatedSessionController extends Controller
15
{
16
    /**
17
     * Display the login view.
18
     */
19
    public function create(): Response
20
    {
21
        return Inertia::render('Auth/Login', [
22
            'canResetPassword' => Route::has('password.request'),
0 ignored issues
show
Bug introduced by
The method has() does not exist on Illuminate\Support\Facades\Route. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
            'canResetPassword' => Route::/** @scrutinizer ignore-call */ has('password.request'),

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
            'status' => session('status'),
24
        ]);
25
    }
26
27
    /**
28
     * Handle an incoming authentication request.
29
     */
30
    public function store(LoginRequest $request): RedirectResponse
31
    {
32
        $request->authenticate();
33
34
        $request->session()->regenerate();
0 ignored issues
show
Bug introduced by
The method session() does not exist on App\Http\Requests\Auth\LoginRequest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $request->/** @scrutinizer ignore-call */ 
35
                  session()->regenerate();

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...
35
36
        return redirect()->intended(route('dashboard', absolute: false));
37
    }
38
39
    /**
40
     * Destroy an authenticated session.
41
     */
42
    public function destroy(Request $request): RedirectResponse
43
    {
44
        Auth::guard('web')->logout();
45
46
        $request->session()->invalidate();
0 ignored issues
show
Bug introduced by
The method session() does not exist on Illuminate\Http\Request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
        $request->/** @scrutinizer ignore-call */ 
47
                  session()->invalidate();

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...
47
48
        $request->session()->regenerateToken();
49
50
        return redirect('/');
51
    }
52
}
53