I'm a pretty terrible (new) web developer, I have been getting my head round codeigniter over the last couple of weeks and learning OOP. I have started a project on CI and needed an auth library and various blog posts led me to Tank Auth.
My project needs user roles, and also the user name to be stored with initial login. So against all the principles I have read in the thread I have modified the users table and library to allow me to display info based on the users role.
The changes I made are as follows.
Added 'role' and 'full_name' to the Users table
In the Tank_auth.php file (library) on lines 76/77 (login method) I added
Therefore login status, the users name and their role is available to all my view files without having to code it in every additional controller I make.
The reason I extended tank_auth rather than creating a new way of accessing the user_profiles table was that I didn't want to load additional libraries when I was already calling tank_auth, which was fulfilling 99% of the functionality I needed it to. Reduced the amount of code I had to write as well.
I have also changed all the view files, semantically coding login forms in a <table> is incorrect in my opinion! Using <fieldset> or even <ul> is a much cleaner way to style and display forms.
There is currently no way of modifying the users role, however I will add that functionality when I sort out the user management panel for the site admins.
If there are any better ways of doing it, please let me know
(and thanks to Ilya for writing a great library - filling in a massive gap in my knowledge!)
edit: Forgot the addition I made to the register() method in the auth.php controller
Code:
line 141: $this->form_validation->set_rules('your_name', 'Your Name', 'trim|required|xss_clean');