Search code examples
codeigniterion-auth

Changing default functionality in ion auth


I need to change some default functionality of ion auth once a new user has been created by an admin.

The scenario is like so...

  • Admin creates the user account.
  • Activation email is sent to the user.
  • Clicking the link sends the user to the set password page.
  • Upon setting a password, the user is activated and can log in.

Currently I haven't found a way to define the activation link once ion auth calls the register function and the email is sent. It's set to auth/activate.

The options I see are as follows...

Redefine the behaviour of Auth/activate(). Is this recommended though? Should I be touching the methods in the Auth controller?

Turn off $config['email_activation'] and handle everything myself.

Somehow changing the default controller/method behaviour to handle the activation of the user.

What do people usually do in this situation? Which is best practice?


Solution

  • Ok, after much searching I was reading through https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/2/libraries/Ion_auth.php and noticed the email message being generated was being sent to an email_template (in the view), which I had forgot to check. The activate.tpl.php is where you can find the code that generates the path to the Auth controller.

        <?php 
            echo sprintf(lang('email_activate_subheading'), anchor('auth/activate/'. $id .'/'. $activation, lang('email_activate_link')));
        ?>
    

    Now I can just easily change the controller path, it makes sense to write my own controller.