We’ve created an admin area that looks nice. But… It is not secured. Everyone can get in there and do whatever he/she wants. So why not using a well established CodeIgniter library like Ion Auth which has great documentation?
So let’s download it from Github (https://github.com/benedmunds/CodeIgniter-Ion-Auth).
After we’ve downloaded it, we should just copy the files from the package to the corresponding directory in our application.
- copy ion_auth.php from Ion_Auth’s config to your application/config/development
- copy auth.php from Ion_Auth’s controllers to your application/controllers/admin (make sure the name of the file starts with uppercase)
- from language, copy your language directory‘s files into application/language/yourlanguage (where yourlanguage is your language)
- from Ion Auth’s libraries directory copy the files into your application/libraries directory
- from Ion Auth’s models copy ion_auth_model.php inside your application/models directory making sure the file name starts with uppercase (Ion_auth_model.php)
- from Ion Auth’s views directory copy the folder auth inside your application/views directory.
Of course, the library uses databases to keep its information, so let’s import into our database the ion_auth.sql file that can be found inside Ion Auth’s sql directory.
If the import went ok, you should have 4 new tables into your database: groups, login_attempts, users and users_groups
Also, some tables should be prepopulated with the first records. In our next tutorial we will create our login and logout pages.