Welcome Guest, Not a member yet? Register   Sign In
Too Many Redirect error if the redirect call is on the same controller
#1

I just noticed that when I call a redirect where the function is inside the same controller, it causes ERR_TOO_MANY_REDIRECTS error. However, when I call a redirect from another controller, it's working as expected.

Code:
public function _remap($method)
    {
        //code to redirect to login if not logged in
        
        if (auth()->loggedIn()) {
            $user = auth()->user();
            if($user->inGroup('admin','superadmin')){
                return redirect()->to('admin/users'); //this causes ERR_TOO_MANY_REDIRECTS
            } else {
                if($user->toRawArray()['is_paid'] == 0){
                    return redirect()->to('payment'); //this is okay
                } else {
                    return $this->{$method}($user->toRawArray());
                }
            }
        } else {
            return redirect()->to(config('Auth')->loginRedirect());
        }
    }
Reply


Messages In This Thread
Too Many Redirect error if the redirect call is on the same controller - by elimariaaaa - 03-25-2024, 12:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB