Welcome Guest, Not a member yet? Register   Sign In
Redirection issues
#8

(07-10-2020, 11:51 AM)InsiteFX Wrote: Is that method in a controller?

I always use an echo and exit to step through the code to find errors.


PHP Code:
echo $whatever;
exit(); 

I start at the top and work down checking each string and array values to see if there correct.

Also I would check and make sure that your getting the request class in there.

Yes, that method is on a controller.

So friend, if I put the echoes it respects the condition structure and prints accordingly.


PHP Code:
public function isAllowed()
    {
       if(!empty(Utils::getDataSession('username'))) :

        $isAllowed false;

        $routeName Utils::getDataMachine('REQUEST_URI');
        $getPermission Utils::getDataSession('permission');
        
            
if (in_array($routeName$this->exception)) :
                $isAllowed true;
            else :

                foreach ($getPermission as $key => $value) :

                    if ($value == $routeName) :
                        $isAllowed true;
                    endif;

                endforeach;

                $permission = new Permission;

                if (!$isAllowed) :
                    //return redirect()->route('dashboard');
                    echo "false";
                endif;

            endif;

        return $isAllowed;

        else :
            echo "else";
            //return redirect()->route('/');
        endif;
    

If I put it to redirect with javascript it works normally

PHP Code:
public function isAllowed()
    {
       if(!empty(Utils::getDataSession('username'))) :

        $isAllowed false;

        $routeName Utils::getDataMachine('REQUEST_URI');
        $getPermission Utils::getDataSession('permission');
        
            
if (in_array($routeName$this->exception)) :
                $isAllowed true;
            else :

                foreach ($getPermission as $key => $value) :

                    if ($value == $routeName) :
                        $isAllowed true;
                    endif;

                endforeach;

                $permission = new Permission;

                if (!$isAllowed) :
                    echo "<script>window.location.href='dashboard'</script>";
                endif;

            endif;

        return $isAllowed;

        else :
            echo "<script>window.location.href='/'</script>";
        endif;
    
Reply


Messages In This Thread
Redirection issues - by Wickfield - 07-09-2020, 11:13 AM
RE: Redirection issues - by Wickfield - 07-09-2020, 11:22 AM
RE: Redirection issues - by marcogmonteiro - 07-10-2020, 01:24 AM
RE: Redirection issues - by Wickfield - 07-10-2020, 10:05 AM
RE: Redirection issues - by InsiteFX - 07-10-2020, 06:37 AM
RE: Redirection issues - by Wickfield - 07-10-2020, 10:06 AM
RE: Redirection issues - by InsiteFX - 07-10-2020, 11:51 AM
RE: Redirection issues - by Wickfield - 07-10-2020, 01:34 PM
RE: Redirection issues - by InsiteFX - 07-11-2020, 03:16 AM
RE: Redirection issues - by Wickfield - 07-11-2020, 07:57 AM
RE: Redirection issues - by InsiteFX - 07-11-2020, 09:40 AM
RE: Redirection issues - by Wickfield - 07-13-2020, 07:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB