Welcome Guest, Not a member yet? Register   Sign In
My_Controller issue
#1

[eluser]ericsodt[/eluser]
So I am doing some filtering at the controller level. I am making sure that a regular user stays within the regular user section and the admins stay within the admin section.

To do this, I extended the Controller and built some logic around it
Code:
function validate(){        
    $inAdminSection = $this->uri->segment(1) == 'admin'?true:false;
    
    if(!$this->session->userdata("isAdmin")&& $inAdminSection ){
        redirect('profile/adminLogin');
        
    }
    if($this->session->userdata("isAdmin") && !$inAdminSection && $loggingOut){
        redirect('admin/admin/index');
    }        
        
    return;
}

Everything works fine except when I try and log an admin out. It sees that it is not in the admin section and is an admin, which then throws them back to where they were.

I am just trying to pass any values to the Controller that would have been passed to the calling method. For example, to log out the url is "welcome/index". This checks to see if the user is logging out and if so completes this action. This method however will never get called because of My_Controller. I was thinking of passing a variable through it as so "welcome/index/logout" but I am having a hard time figuring out how My_Controller can see the parameter.

Does anyone know how a Controller can capture what is being passed to the desired method?


Thanks!
#2

[eluser]bretticus[/eluser]
Why not just have a separate controller method for logging out and not calling validate() on it?

BTW:

You can get the current controller with $this->router->class and you can get the current model with $this->router->method.

You can get logout in welcome/index/logout via $this->uri->segment(3).
#3

[eluser]ericsodt[/eluser]
validate is to make sure that the admins can only access admin modules and 'regular' users can not access admin modules.


[quote author="bretticus" date="1252545470"]Why not just have a separate controller method for logging out and not calling validate() on it?[/quote]
#4

[eluser]bretticus[/eluser]
[quote author="ericsodt" date="1252545591"]validate is to make sure that the admins can only access admin modules and 'regular' users can not access admin modules.


[quote author="bretticus" date="1252545470"]Why not just have a separate controller method for logging out and not calling validate() on it?[/quote][/quote]

Do you need to validate a log out???

BTW, I added some things to my original post.




Theme © iAndrew 2016 - Forum software by © MyBB