Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    laravel redirect to wrong url after auth success

    Laravel Framework
    laravel laravel 8 php error
    2
    3
    491
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • KrissSachintha
      KrissSachintha last edited by

      guys I need a help, I deployed a laravel app inside domain/external folder and in the laravel app index.php i changed the paths to /../external/storage etc.
      when I go to the domain it will redirect me to domain/external perfectly but however after I login in the laravel app the Auth module will redirect me to domain/ instead of domain/external
      how to fix it,
      I already tried this inside authcontroller but won't work
      protected function redirectTo()
      {
      return '/path';
      }

      lkdev 1 Reply Last reply Reply Quote 0
      • lkdev
        lkdev @KrissSachintha last edited by

        @krisssachintha

        overide login function.

        inside login controller (app/Http/Controllers/Auth/LoginController.php)

        <?php
          
        namespace App\Http\Controllers\Auth;
          
        use App\Http\Controllers\Controller;
        use App\Providers\RouteServiceProvider;
        use Illuminate\Foundation\Auth\AuthenticatesUsers;
        use Illuminate\Http\Request;
        use Auth;
           
        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 = RouteServiceProvider::HOME;
           
            /**
             * Create a new controller instance.
             *
             * @return void
             */
            public function __construct()
            {
                $this->middleware('guest')->except('logout');
            }
          
             /**
             * Write code on Method
             *
             * @return response()
             */
            public function login(Request $request)
            {
                $request->validate([
                    'email' => 'required',
                    'password' => 'required',
                ]);
             
                $credentials = $request->only('email', 'password');
                if (Auth::attempt($credentials)) {
          
                    return redirect()->route('home');
                }
            
                return redirect("login")->withSuccess('Oppes! You have entered invalid credentials');
            }
        }
        
        KrissSachintha 1 Reply Last reply Reply Quote 1
        • KrissSachintha
          KrissSachintha @lkdev last edited by

          @lkdev bro in my laravel app there is only authController regarding login, is it normal? however I solved the issue, the issue was the subdomain which I was given was inside another subdomain so the laravel app goes crazy, so what I did was created a separate subdomain in a new hosting and tried, and that worked.

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post

          1
          Online

          3.6k
          Users

          1.3k
          Topics

          5.3k
          Posts

          • Privacy
          • Terms & Conditions
          • Donate

          © Copyrights and All right reserved Lanka Developers Community

          Powered by Axis Technologies (PVT) Ltd

          Made with in Sri Lanka

          | |