inertia-laravel icon indicating copy to clipboard operation
inertia-laravel copied to clipboard

return Inertia::location($url); appearing in Modal Popup

Open kinger251285 opened this issue 3 years ago • 0 comments

Laravel: 8.65 inertiajs/inertia-laravel: 0.4.3 laravel/jetstream: 2.4

I have a middleware to check whether a user is an admin or has a team role. The middleware redirects based on admin or normal user.

isAdmin.php

public function handle(Request $request, Closure $next)
    {        
          $team = Auth::user()->teams->first();    
        

          if (Auth::user()->role == 'admin' || Auth::user()->hasTeamRole($team, 'admin')){            
            return $next($request);
          } else {

            
            $url = env('APP_URL');
            /*
            return Inertia::location($url.'/dashboard');
            //return Redirect::route('user.dashboard');
            */

            if ($request->ajax()) {
              return Inertia::location($url.'/dashboard');
            }

            return Inertia::location($url.'/dashboard');
          }
    }    

The admin navigates correctly and returns the user to the admin dashboard. However the normal users stay on the login screen and the dashboard appears in a popup modal rather than redirecting to the dashboard.

This also happens when i logout form the admin dashboard (Not such a big issue).

It appears to only happen on external links. The Admin panel is a Vue Inertia Jetstream and the main front end is standard blade templateing hence the external link.

kinger251285 avatar Feb 11 '22 16:02 kinger251285