Support the ongoing development of Laravel.io →
Authentication

i use module in my project

App -> 
   Modules ->
          Admin -> 
                Http ->
                     controller
                     middleware
                     request

how i use authenticate and redirect auth file in this middleware authenticate file or redirectauth file in this middleware authenticate.php

public function handle($request, Closure $next)
    {
        if ($this->auth->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                // return redirect()->guest('auth/login');
                return redirect()->guest('admin');
            }
        }

        return $next($request);
    }

redirectauthenticate.php

public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {
            // return redirect('/home');
            return redirect('admin/dashbord');
        }

        return $next($request);
    }

How i solve this ?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.