inertiajs / inertia-laravel

The Laravel adapter for Inertia.js.
https://inertiajs.com
MIT License
2.09k stars 235 forks source link

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

Closed kinger251285 closed 1 year ago

kinger251285 commented 2 years ago

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.

jessarcher commented 1 year ago

Hey there,

We're closing this issue because it's inactive, already solved, old or not relevant anymore. Feel free to open up a new issue if you're still experiencing this problem.