ssquare
5 months ago
3768
32
Laravel

Laravel got stuck after login. Laravel 5.8

Posted 5 months ago by ssquare

I have done following:

Go to Login Page: amenity.local/login (or if I enter amenity.local it will redirect me to amenity.local/login) and after hitting enter the fav-icon shows loading forever and it got stuck there no results, no error, no timeout, nothing.

However, I could login with following cases:

  1. If I am already logged in and if I logged out. This will opens amenity.local/login page. Again, this time I could logged in easily without any hassle.

  2. If I am already logged in and then if I tried to access amenity.local/login then it will redirect to amenity.local/admin/property directly without showing login page.

But, As I have already mentioned, if I enter amenity.local/login in new page and enter credentials, then it stuck there forever. However, if I hit F5 (refresh) the page then it loads amenity.local/admin/property.

Login Controller

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/admin/property';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }


}

RedirectIfAuthenticated

class RedirectIfAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return redirect('/admin/property');
        }
        return $next($request);
    }
}

Route

Auth::routes(['verify' => true]);

Route::get('/', function () {
    return redirect()->route('property.index');
});

Route::group(['middleware' => ['auth','verified']], function() {
    Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function () {
    	Route::resource('property','PropertyController')->except(['create']);
    });
});  

route:list

| GET|HEAD | /  			 |   			  | Closure | web  
| GET|HEAD | admin/property  | property.index | App\Http\Controllers\Admin\[email protected] |verified   
| POST     | login 			 | 				  |App\Http\Controllers\Auth\[email protected] | web,guest

Please sign in or create an account to participate in this conversation.