Middleware auth logging me out?


I'm a bit new to laravel (and coding in general), so sorry if this question is basic!

My issue right now is that without the 'middleware' => 'auth', I'm able to log into the Dashboard, but with the 'middleware' => 'auth' implemented, the screen flickers, as though I've logged in and then logged out immediately thereafter.

What exactly am I doing wrong?

Thanks for the help in advance!

Here's the routing:

Route::post('/signin', [
    'uses' => 'UserController@postSignIn',
    'as' => 'signin'

Route::get('/dashboard', [
    'uses' => 'UserController@getDashboard',
    'as' => 'dashboard',
    'middleware' => 'auth'

Redirect if Authenticated


namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class RedirectIfAuthenticated
    public function handle($request, Closure $next, $guard = null)
        if (Auth::guard($guard)->check()) {
            return redirect('dashboard');

        return $next($request);

User Controller

    public function postSignIn(Request $request)
        $this->validate($request, [
            'email' => 'required',  
            'password' => 'required'
        if (Auth::attempt(['email' => $request['email'], 'password' => $request['password']])) {
            return redirect()->route('dashboard');
        return redirect()->back();

    public function getDashboard()
        return view('dashboard');

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us