Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Filter?
#1

[eluser]Unknown[/eluser]
I am working on the admin side of a site that I am building and wanted to lock it down. I already figured out how to do my authentication, but I am looking for a way to call this authentication function on every request being made in this controller without having to call it at the beginning of each controller method. Is there a way to pass request through a filter, or something of the sort, in the constructor?

Ex.
Code:
public function __construct()
{
  filter(authenticate(), 'login,signin');
}

Where the first parameter is the method being called, and the second parameter is the methods to exclude from the filter. Because you wouldn't want to check for a logged in user if they are on the login page or if the signin method is being used since it is the one logging them in. Does anyone know if there is a way to do this? I think it would cut back on me repeating the call to authenticate before each locked down method.

Thanks!
#2

[eluser]Unknown[/eluser]
Found the _remap function...didn't see this before. I simply did the following:
Code:
function _remap($method)
    {
        if($method != 'index' && $method != 'signin')
        {
            $this->authenticate();
            $this->$method();
        }
        else
        {
            $this->$method();
        }
    }




Theme © iAndrew 2016 - Forum software by © MyBB