Back

Laravel RedirectIfAuthenticated not working


Laravel RedirectIfAuthenticated not working after moving from XAMPP to Laragon Previously I used XAMPP, then migrated to Laragon. when still using XAMPP my application is still functioning properly, but after migrating to Laragon it turns out that my application has an error, namely RedirectIfAuthenticated does not work, and even though the User name that is currently logged appears in the application header, but the session user that is currently logged does not appear when debug on Clockwork. Has anyone ever experienced the same thing here? how is the solution, I see on Google it seems that no one has discussed this issue.

this is RedirectifAuthenticated Class

<?php

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()->route('home');
        }
        return $next($request);
    }
}

this is my login controller, i using default auth

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{  

    use AuthenticatesUsers; 
    protected $redirectTo = '/home';   
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
}

my master blade

{{--layout header--}}
@include('layouts.header')

{{-- @includeWhen(Auth::user(),'layouts.topbar') --}}
{{--jika sudah login, maka sidebar akan muncul--}}

@if(Auth::check())
  @include('layouts.topbar')
  @include('layouts.sidebar')
@endif
{{-- @includeWhen(Auth::user(),'layouts.sidebar') --}}
{{--layout konten--}}
@yield('content')

{{-- {{(Auth::user())}} --}}
{{-- {{ --}}
  {{-- clock(Auth::user()) --}}
{{--layout footer--}}
@include('layouts.footer')

Thanks!


Sign in to participate in this thread!



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