Q:

Laravel - Form back with Input

I'm doing a login form with laravel. What I want is to validate the POST values, and if it's OK, then redirect to dashborad. If not, redirect back with Input. This is my login form :
        <form method="post" autocomplete="off">
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <div class="form-group">
                <label for="email">Adresse courriel:</label>
                <input type="email" class="form-control" id="email" name="email" required>
            </div>
            <div class="form-group">
                <label for="password">Mot de passe:</label>
                <input type="password" class="form-control" id="password" name="password" required>
            </div>
            <button type="submit" class="btn btn-aqua">Se connecter</button>
        </form>

And this is my AuthController function :
public function postLogin(Request $request){

     Log::info('Showing user profile for user: '.$request);

    if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
        return redirect()->route('/admin/dashboard');
    }

    return redirect()->back()->withInput(Input::all());
}

When it's redirecting back, my input are note filled.

A:

Laravel implements a old() function which brings back input data if the form submitted has errors:
<form method="post" autocomplete="off">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
    <div class="form-group">
        <label for="email">Adresse courriel:</label>
        <input type="email" class="form-control" id="email" name="email" required value="{{ old('email') }}">
    </div>
    <div class="form-group">
        <label for="password">Mot de passe:</label>
        <input type="password" class="form-control" id="password" name="password" required>
    </div>
    <button type="submit" class="btn btn-aqua">Se connecter</button>
</form>

I strongly recommend to not bring back the password. I know this is annoying, but safer imo.
More info : https://laravel.com/docs/5.4/requests#old-input

