简体   繁体   English

Laravel-Localhost重定向您太​​多次

[英]Laravel - Localhost redirected you too many times

We had one app developed almost a year ago and here I'm facing a problem. 大约一年前,我们开发了一个应用程序,在这里我遇到了一个问题。 After signing in the chrome says: The localhost page isn't working, localhost redirected you too many times. 登录Chrome后说: The localhost page isn't working, localhost redirected you too many times. . And the problem lies in this piece of code at controller that while I remove it, it works fine. 问题出在控制器上的这段代码,当我删除它时,它可以正常工作。 I couldn't figure out what is wrong with this. 我不知道这是怎么回事。

if(Auth::check()){
        $usertype=usertype::where('uid','=',Auth::user()->id)->first();
        if(isset($usertype)){
        if($usertype->type==1){
            $shopcatagory=shopcatagory::where('sid','=',Auth::user()->id)->first();
            $shopsubcatagory=shopsubcatagory::where('sid','=',Auth::user()->id)->first();
            $shopphone=shopphone::where('sid','=',Auth::user()->id)->first();
            $shopaddress=shopaddress::where('sid','=',Auth::user()->id)->first();
            $shopplace=shopplace::where('sid','=',Auth::user()->id)->first();
            if(!isset($shopaddress) || !isset($shopcatagory) || !isset($shopsubcatagory) || !isset($shopphone) || !isset($shopplace)){
                return Redirect::action('HomeController@accountinfo',Auth::user()->id);
            }
        }

        else if($usertype->type==3){
            $shopphone=shopphone::where('sid','=',Auth::user()->id)->first();
            $shopaddress=shopaddress::where('sid','=',Auth::user()->id)->first();
            $shopplace=shopplace::where('sid','=',Auth::user()->id)->first();
            if(!isset($shopaddress) || !isset($shopphone) || !isset($shopplace)){
                return Redirect::action('HomeController@accountinfo',Auth::user()->id);
            }
        }

        else if($usertype->type == 2){
            $userinterests=userinterests::where('uid','=',Auth::user()->id)->first();
            if(!isset($userinterests)){
                return Redirect::action('HomeController@interests');
            }
        }

        }
    }

In this big Auth::check block, there are two different routes that you are potentially redirecting to: accountinfo and interests . 在这个大的Auth::check块中,有两种可能会重定向到的不同路由: accountinfointerests

So if you are getting stuck in an infinite loop, then it sounds like this very code is running on one (or both) of those very routes! 因此,如果您陷入无限循环,那么听起来这两个代码中的一个(或两个)都运行着这个代码!

Track that down, make sure that neither of those two routes include this Auth::check code with the redirects. 进行跟踪,请确保这两个路由都不包含带有重定向的Auth::check代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM