Hi all,
it is my first post, also is my first contribution to the codeigniter community
. I found this fantastic framework the last thursday and after to read the documentation finally I made a very useful (for me
) User Authentification library. I have used Auth PEAR Class in my projects, but now I have seen the light
and I learned to use CodeIgniter. Sorry I have tested UserAuth MiniApp but I think that in some project you only need a simple authentification, and you don’t need groups. So based in Auth PEAR Class that it is very very simple to use, I have made some similar.
The Code in Here
The Sample DEMO in Here (username: admin , password: admin)
UPDATE: 11/10/2006
- Comments in all methods compatible with phpdoc
- Minor changes for CodeIgniter 1.5.0.1 with Unix systems (problems with php filenames in sensitive case)
- Password is stored in md5 in the cookie session (in login allways check with database)
- Init file deleted (in CodeIgniter 1.5.0.1 init is automatic)
UPDATE: 11/01/2006
- Rsauth is compatible with CodeIgniter 1.5.0.1 without changes.
UPDATE: revision 0.2 10/30/2006
- Fix adduser and updatepassword in model
- Add userExists in rsauth Library for checking is the user already exists (for not adduser by example).
The readme file:
=================================================
Rsauth library tested in Codeigniter 1.4.1
author SeViR CW · http://www.sevir.org/en/
revision 0.1 10/29/2006
=================================================
Rsauth is a Really Simple Authentification Library. This idea
is based in Auth PEAR Class but, I change some features for
simplify more.
1. INSTALLATION
Decompress rsauth.zip in your codeigniter installation directory.
2. CONFIGURATION
In your config application directory you can find database.php file,
you need configure correctly database config.
Also you can find a rsauth.php config file. This config file only has
four params:
rsauth_table = is the name of the table to store username and password data
rsauth_adminuser = the first user is created with this username automatically
rsauth_adminpassword = the password for this first user
rsauth_dbdriver = typically is the same as database driver (mysql, posgre,...)
3. DEMO
Change your default_controller in config/routes.php for “demorsauth” and test
NOTE: The first time that you use this library, checks if rsauth table exists,
and if it doesn’t exist, it is automatically created with one user configurated
as rsauth_adminuser and rsauth_adminpassword.
4. RSAUTH LIBRARY
$this->load->library(“rsauth”); //load the library
$loginform = $this->rsauth->login($showloginform); //Authentification routine,
if $showloginform is TRUE then returns (views/rsauth/rsauthform.php view) if
you don’t login or the login data is incorrect.
$this->rsauth->check(); //check if the user is logged
$this->getUser(); //returns the username logged
$this->rsauth->logout(); //logout
5. RSAUTH_MNG_MODEL MODEL
Is used by RSAUTH library but also it has some useful functions:
$this->load->model(“rsauth_mng_model”);
$this->rsauth_mng_model->adduser($username,$password); //add one user
$this->rsauth_mng_model->updatepassword($username,$password); //update password
for the user
$this->rsauth_mng_model->getlasterror(); //if adduser or updatepassword methods
faults, this function shows the error
Cheers,
SeViR CW
