Welcome Guest, Not a member yet? Register   Sign In
redirect() in base controller
#1

Hi,
In my baseController I've got a function that check if user's role is compatible with the controller's roles.
Here is this function :
PHP Code:
function check(array $roles) {
       
        
if (!isset($_SESSION['role'])) {
            die("<p>Aucun rôle défini. Vous ne pouvez accéder à cette fonctionnalité.</p>");
        }
        else {
            if (in_array($_SESSION['role'], $roles)) {
                return TRUE;
            } else {
                return redirect()->to("http://localhost/g/public/index.php/");
                die("<p>Vous ne pouvez accéder à cette fonctionnalité.</p>");
            }
        }
    
This function works but not the redirection. If user's role isn't in $roles redirection doesn't apply.
I read and search about using redirect function in basecontroller but wasn't able to find a solution.

Any idea ?
If you think that I'm trying to do it in a wrong way tell it to me.

Thanks
Reply


Messages In This Thread
redirect() in base controller - by sTis - 03-16-2023, 02:18 AM
RE: redirect() in base controller - by kenjis - 03-16-2023, 04:02 AM
RE: redirect() in base controller - by sTis - 03-16-2023, 06:00 AM
RE: redirect() in base controller - by kenjis - 03-16-2023, 05:08 PM
RE: redirect() in base controller - by sTis - 03-17-2023, 03:02 AM
RE: redirect() in base controller - by sTis - 03-19-2023, 09:55 AM
RE: redirect() in base controller - by InsiteFX - 03-19-2023, 11:26 PM
RE: redirect() in base controller - by iRedds - 03-20-2023, 03:20 AM
RE: redirect() in base controller - by sTis - 03-24-2023, 05:50 AM
RE: redirect() in base controller - by Muzikant - 04-19-2023, 02:51 AM
RE: redirect() in base controller - by kenjis - 04-19-2023, 03:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB