title: Laravel 8 Multi Auth with Jetstream livewire
body: <p>im trying to setup a multi auth system in laravel 8 with jetstream livewire in my ecomm project (one login page for admins(/admin/login) and another for users(/login))
  i have followed a tutorial and everything is ok expect when i login to user from /login page i can access /admin/dashboard with that user and with admin its fine and cant access user /dashboard</p>
  <p><strong>routes\web.php</strong>:</p>
  <pre><code>Route::get('/', function () {
      return view('welcome');
  });
  
  Route::group(['prefix'=&gt;'admin','middleware'=&gt;['admin:admin']],function(){
      Route::get('/login', [AdminController::class, 'loginForm']);
      Route::post('/login', [AdminController::class, 'store'])-&gt;name('admin.login');
      Route::get('/logout', [AdminController::class, 'Logout'])-&gt;name('admin.logout');
  });
  
  Route::middleware(['auth:sanctum,admin', 'verified'])-&gt;get('/admin/dashboard', function () {
      return view('admin.index');
  })-&gt;name('dashboard.admin');
  
  
  Route::middleware(['auth:sanctum,web', 'verified'])-&gt;get('/dashboard', function () {
      return view('dashboard');
  })-&gt;name('dashboard');
  </code></pre>
  <p><strong>Models\Admin.php</strong>:</p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  use Illuminate\Notifications\Notifiable;
  use Laravel\Fortify\TwoFactorAuthenticatable;
  use Laravel\Jetstream\HasProfilePhoto;
  use Laravel\Sanctum\HasApiTokens;
  
  class Admin extends Authenticatable
  {
      use HasApiTokens;
      use HasFactory;
      use HasProfilePhoto;
      use Notifiable;
      use TwoFactorAuthenticatable;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
  
  
      protected $fillable = [
          'name',
          'email',
          'password',
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password',
          'remember_token',
          'two_factor_recovery_codes',
          'two_factor_secret',
      ];
  
      /**
       * The attributes that should be cast to native types.
       *
       * @var array
       */
      protected $casts = [
          'email_verified_at' =&gt; 'datetime',
      ];
  
      /**
       * The accessors to append to the model's array form.
       *
       * @var array
       */
      protected $appends = [
          'profile_photo_url',
      ];
  }
  </code></pre>
  <p><strong>Controllers\AdminController.php</strong>:</p>
  <pre><code>&lt;?php
  
  
  
  namespace App\Http\Controllers;
  
  use Illuminate\Contracts\Auth\StatefulGuard;
  use Illuminate\Http\Request;
  use Illuminate\Routing\Controller;
  use Illuminate\Routing\Pipeline;
  use App\Actions\Fortify\AttemptToAuthenticate;
  use Laravel\Fortify\Actions\EnsureLoginIsNotThrottled;
  use Laravel\Fortify\Actions\PrepareAuthenticatedSession;
  use App\Actions\Fortify\RedirectIfTwoFactorAuthenticatable;
  use App\Http\Responses\LoginResponse;
  use Laravel\Fortify\Contracts\LoginViewResponse;
  use Laravel\Fortify\Contracts\LogoutResponse;
  use Laravel\Fortify\Features;
  use Laravel\Fortify\Fortify;
  use Laravel\Fortify\Http\Requests\LoginRequest;
  use Auth;
  
  
  class AdminController extends Controller
  {
      /**
       * The guard implementation.
       *
       * @var \Illuminate\Contracts\Auth\StatefulGuard
       */
      protected $guard;
  
      /**
       * Create a new controller instance.
       *
       * @param \Illuminate\Contracts\Auth\StatefulGuard
       * @return void
       */
      public function __construct(StatefulGuard $guard, Request $request)
      {
          $this-&gt;guard = $guard;
      }
  
  
      public function loginForm(){
          return view('admin.login',['guard'=&gt;'admin']);
      }
  
      public function Logout(){
          Auth::logout();
          return Redirect()-&gt;url('admin/login')-&gt;with('success', 'Logged Out');
      }
  
  
  
      /**
       * Show the login view.
       *
       * @param \Illuminate\Http\Request $request
       * @return \Laravel\Fortify\Contracts\LoginViewResponse
       */
      public function create(Request $request): LoginViewResponse
      {
          return app(LoginViewResponse::class);
      }
  
      /**
       * Attempt to authenticate a new session.
       *
       * @param \Laravel\Fortify\Http\Requests\LoginRequest $request
       * @return mixed
       */
      public function store(LoginRequest $request)
      {
          return $this-&gt;loginPipeline($request)-&gt;then(function ($request) {
              return app(LoginResponse::class);
          });
      }
  
      /**
       * Get the authentication pipeline instance.
       *
       * @param \Laravel\Fortify\Http\Requests\LoginRequest $request
       * @return \Illuminate\Pipeline\Pipeline
       */
      protected function loginPipeline(LoginRequest $request)
      {
          if (Fortify::$authenticateThroughCallback) {
              return (new Pipeline(app()))-&gt;send($request)-&gt;through(array_filter(
                  call_user_func(Fortify::$authenticateThroughCallback, $request)
              ));
          }
  
          if (is_array(config('fortify.pipelines.login'))) {
              return (new Pipeline(app()))-&gt;send($request)-&gt;through(array_filter(
                  config('fortify.pipelines.login')
              ));
          }
  
          return (new Pipeline(app()))-&gt;send($request)-&gt;through(array_filter([
              config('fortify.limiters.login') ? null : EnsureLoginIsNotThrottled::class,
              Features::enabled(Features::twoFactorAuthentication()) ? RedirectIfTwoFactorAuthenticatable::class : null,
              AttemptToAuthenticate::class,
              PrepareAuthenticatedSession::class,
          ]));
      }
  
      /**
       * Destroy an authenticated session.
       *
       * @param \Illuminate\Http\Request $request
       * @return \Laravel\Fortify\Contracts\LogoutResponse
       */
      public function destroy(Request $request): LogoutResponse
      {
          $this-&gt;guard-&gt;logout();
  
          $request-&gt;session()-&gt;invalidate();
  
          $request-&gt;session()-&gt;regenerateToken();
  
          return app(LogoutResponse::class);
      }
  }
  </code></pre>
  <p><strong>Responses\LoginResponse.php</strong>:</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Responses;
  
  use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract;
  
  class LoginResponse implements LoginResponseContract
  {
      /**
       * Create an HTTP response that represents the object.
       *
       * @param  \Illuminate\Http\Request  $request
       * @return \Symfony\Component\HttpFoundation\Response
       */
      public function toResponse($request)
      {
          return $request-&gt;wantsJson()
              ? response()-&gt;json(['two_factor' =&gt; false])
              : redirect()-&gt;intended('admin/dashboard');
      }
  }
  </code></pre>
  <p>i also created a copy of StatefulGuard in App\Guards\AdminStatefulGuard.php following that tutorial but never used it.</p>