codeignitertankauth

How do I change the login URL using Tank auth?


I have been looking around the Tank auth code to see how things are done, but it seems a little confusing to find out how to change the path of the default login.

I wanted to change it to groups/login or users/sign_in, but that wasn't an easy task. I'm wondering whether I should change that from the routing file or any other file.

Any idea how to get around with this little issue?


Solution

  • I'm wondering whether I should change that from the routing file

    Yes, that's exactly what URI Routing is for:

    $route['your/desired/url'] = 'auth/login';
    

    If you need to kill the old URL for some reason, you can set it to something empty:

    $route['auth/login'] = FALSE;
    

    Unfortunately, the Tank Auth login url is assumed to be auth/login, and there are several redirects that must be edited. I recommend adding a custom config setting to config/tank_auth.php:

    $config['login_url'] = 'your/desired/url';
    

    Then replace all occurrences of redirect('/auth/login') with:

    redirect($this->config->item('login_url', 'tank_auth'));
    

    in the Auth controller and anywhere else it appears.