Step 3.4 – Creating the profile page with Ion Auth

(Created at: February 05, 2015; Las update: March 11, 2016

All good and well: we’ve done our login and logout pages, we’ve facilitated the administration of users and groups using Ion Auth. But what about the profile page? What if the user wants to change his/her credentials or our default password (which, shockingly, is… “password”).

For this it would be nice to have a profile page, where the user can do his/her own changes. We will not allow the user to change its own email or username, even if it is an admin. We should let this part in the hands of the other administrators (but you can do whatever you want in the end).

For the profile page we will create a profile() method inside the application/controllers/admin/User.php controller.

So let’s first modify the top menu (application/views/templates/_parts/admin_master_header_view.php) in order to put a link to the profile page.

Now going to our User.php we create the profile() method that, after interrogating the database, will output the profile page:

Nice… Now the application/views/admin/user/profile_view.php:


And that’s it: we can say that we’ve set up the security. Did I miss something? Please write a comment below.

A good advice would be to delete the Auth.php that we’ve pasted from the Ion_Auth library, so that there won’t be any doubts about what controller(s) will be used from now on for authentication.

If you’ve followed my tutorials you should have at least what I have. Here is the application and assets directories for the application we’ve developed so far.

0 thoughts on “Step 3.4 – Creating the profile page with Ion Auth

  • Hi! I dont understood only one thing – why you saving password like usual string? How I that password saved in DB like crypted string

  • User class extends on MY_Controller not Admin_Controller, $this->data[‘current_user’], $this->data[‘current_user_menu’] and $this->data[‘page_title’] variables don’t exist in __construct() function. Instead they are in profile() function, but $this->data[‘user’] exist and $this->data[‘current_user’] not exist. Is it mistake?

    Sorry for my bad English. 🙂

      • Hi Mr. Avenirer,
        Thank you for your nice and very useful ion auth library, it is awesome.
        Would you please tell me that which method have used for hashing the password after the user is registered in DB and is it secure or strongly secure?
        Have you used Bcrypt and salt and if yes why it takes very less time to generate the hash?

    • Hello. You can’t be a normal user and an admin user at the same time. There is only one session between your website and your browser. You could however create some sort of library that could do such a thing.

  • Great tutorial but you have inconsistent folder naming, in previous tutorial you create application/views/admin/users/ but in this tutorial you change that become application/views/admin/user/ missing one character.

  • Hi,

    And a big thanks for this excellent tutorial.

    Just one thing, in the User.php controller, in the profile function it misses the verification rules for the password change:

    $this-> form_validation-> set_rules (‘password’, ‘Password’ ‘min_length [6]’);
    $this-> form_validation-> set_rules (‘password_confirm’, ‘Password confirmation’, ‘matches [password]’);

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

No spam? * Time limit is exhausted. Please reload CAPTCHA.