# Login

To access the other pages the user needs to be logged into his account.

If you are not logged in you can only access the Login page or the Sign Up page. The default url takes you to the Login page. Logging in is possible with already existing credentials. An email and a password must pe provided to log into your account.

The `App\Http\Controllers\Auth\LoginController.php` handles the logging in of an existing user.

    public function login(Request $request)
    {
        $credentials = $request->validate([
            'email' => ['required', 'email'],
            'password' => ['required'],
        ]);

        if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
            $request->session()->regenerate();

            return redirect()->intended('dashboard');
        }

        return back()->withErrors([
            'email' => 'The provided credentials do not match our records.',
        ]);
    }

The user is not able to edit profile or to access other pages because there is a validation of the entered data. If the data does no match with an account from the database the user is instructed to check the credentials.

    $credentials = $request->validate([
        'email' => ['required', 'email'],
        'password' => ['required'],
    ]);

If the user forgot his password he can reset the password or if he doesn't have an account he can sign up.