EllisLab text mark
Advanced Search
3 of 88
3
   
Ion Auth - Lightweight Auth System based on Redux Auth 2
Posted: 28 February 2010 06:50 AM   [ Ignore ]   [ # 31 ]   [ Rating: 0 ]
Avatar
Joined: 2009-08-28
80 posts

Ben and Atno,

since captcha is just a feature of forms, perhaps it makes sens to combine Ion auth with Frank Michel’s great form library:

http://frankmichel.com/formgenlib/

Best regards, Bernd

 
Posted: 01 March 2010 03:39 PM   [ Ignore ]   [ # 32 ]   [ Rating: 0 ]
Avatar
Joined: 2009-08-28
80 posts

Phil and Ben,

ion_auth_model->update_user brings up an database error, if no field of the user table is in the $data-array.

Since I want to change username, password and email, I added an new if-condition:

if(array_key_exists('username'$data) OR array_key_exists('password'$data) OR array_key_exists('email'$data))
        
        
{
            
if(array_key_exists('password'$data))
            
{
                $data[
'password'$this->hash_password($data['password']);
            
}
    
            $this
->db->where($this->ion_auth->_extra_where);
    
            
$this->db->update($this->tables['users']$data, array('id' => $id));
        
 
Posted: 01 March 2010 04:21 PM   [ Ignore ]   [ # 33 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

naren_nag,

The main difference between Ion Auth and DX Auth and most of the other auth systems out there is that Ion Auth doesn’t try to be a complete user management system that in a way over takes your app and has a ton of files.

The goal of Ion Auth is to be as complete a user auth library as possible but to keep everything lightweight and small.  There are only three files required for Ion Auth.

Thanks!

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 01 March 2010 07:22 PM   [ Ignore ]   [ # 34 ]   [ Rating: 0 ]
Joined: 2008-01-18
128 posts

Naren_nag,

I think Ben’s decision to keep the system lightweight is a real plus for developers.

Not to knock DX or any of the other auth solutions out there but Ben’s solution makes updating and even debugging less of a challenge.

Also because it is so lightweight, it isn’t very difficult to see where we can customize it such as adding related tables, etc.

 
Posted: 01 March 2010 11:37 PM   [ Ignore ]   [ # 35 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

2think,

Thanks!


joytopia,

I think I’m missing something.  Please describe the problem and error?


Thanks,

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 02 March 2010 05:19 AM   [ Ignore ]   [ # 36 ]   [ Rating: 0 ]
Avatar
Joined: 2009-08-28
80 posts

Ben,

when trying to update a field from the meta-table, i.e.

$succes $this->ion_auth->update_user($usernr, array('first_name' => $first_name)); 

I get a database error, because the model tries to update the users-table too, but there is nothing to update. Look at the model:

if(array_key_exists('password'$data))
            
{
                $data[
'password'$this->hash_password($data['password']);
            
}
    
            $this
->db->where($this->ion_auth->_extra_where);
    
            
$this->db->update($this->tables['users']$data, array('id' => $id)); 

Either the closing brace of the if-condition should be placed two lines later, than only the password can be updated. Or a second if-condition is needed to allow the fields that can be changed and prevent the update-routine from being performed, when there is no field to be updated. This is what I did in my last post.

 
Posted: 02 March 2010 08:09 AM   [ Ignore ]   [ # 37 ]   [ Rating: 0 ]
Joined: 2009-10-04
189 posts

Hi,

I need an Auth System, but I don’t know If I should to develop one, or use a system like Ion Auth. My problem is that the information is very specific. It should be easy to change te database tables structure in Ion Auth?

Best Regards,

 
Posted: 02 March 2010 09:30 AM   [ Ignore ]   [ # 38 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-11
2985 posts
Sinclair - 02 March 2010 01:09 PM

Hi,

I need an Auth System, but I don’t know If I should to develop one, or use a system like Ion Auth. My problem is that the information is very specific. It should be easy to change te database tables structure in Ion Auth?

Best Regards,

You can change the name of any of the tables in the config file, and you can add any extra data you like to the ‘meta’ table. First name & last name is there already and you can add phone numbers, membership info, msn handles, etc.

 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

 
Posted: 02 March 2010 08:23 PM   [ Ignore ]   [ # 39 ]   [ Rating: 0 ]
Joined: 2009-10-04
189 posts

Hi,

Thanks for the reply.

One more question. How it works the “create_user”? Only admins can create users in the example code?

Best Regards,

 
Posted: 02 March 2010 08:31 PM   [ Ignore ]   [ # 40 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

Hey Sinclair,

The create_user() method in the example code is just an example.  Feel free to use the register_user() method of the library in whatever way you need.

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 03 March 2010 08:39 PM   [ Ignore ]   [ # 41 ]   [ Rating: 0 ]
Joined: 2009-10-04
189 posts

Thanks for the reply.

I will use the Ion Auth for the project. Thanks a lot!

I will use postgreSQL database, here is the model for test purposes.

CREATE TABLE "users" (
    
"id" SERIAL NOT NULL,
    
"group_id" int4 NOT NULL,
    
"ip_address" char(16NOT NULL,
    
"username" varchar(15NOT NULL,
    
"password" varchar(40NOT NULL,
    
"email" varchar(40NOT NULL,
    
"activation_code" varchar(40),
    
"forgotten_password_code" varchar(40),
    
"active" int4,
  
PRIMARY KEY("id"),
  
CONSTRAINT "check_id" CHECK(id >= 0),
  
CONSTRAINT "check_group_id" CHECK(group_id >= 0),
  
CONSTRAINT "check_active" CHECK(active >= 0)
);


CREATE TABLE "meta" (
    
"id" SERIAL NOT NULL,
    
"user_id" int4,
    
"first_name" varchar(50),
    
"last_name" varchar(50),
    
"company" varchar(100),
    
"phone" varchar(20),
  
PRIMARY KEY("id"),
  
CONSTRAINT "check_id" CHECK(id >= 0),
  
CONSTRAINT "check_user_id" CHECK(user_id >= 0)
);


CREATE TABLE "groups" (
    
"id" SERIAL NOT NULL,
    
"name" varchar(20NOT NULL,
    
"description" varchar(100NOT NULL,
  
PRIMARY KEY("id"),
  
CONSTRAINT "check_id" CHECK(id >= 0)
);


INSERT INTO groups (idnamedescriptionVALUES
    
(1,'admin','Administrator'),
    (
2,'members','General User');
    
INSERT INTO meta (iduser_idfirst_namelast_namecompanyphoneVALUES
    
('1','1','Admin','istrator','ADMIN','0');
    
INSERT INTO users (idgroup_idip_addressusernamepasswordemailactivation_codeforgotten_password_codeactiveVALUES
    
('1','1','127.0.0.1','administrator','59beecdf7fc966e2f17fd8f65a4a9aeb09d4a3d4','admin@admin.com','',NULL,'1'); 

In the project I will not use postgreSQL sequences(same as auto increment of MySQL). I will use triggers instead.

Here to share.


Best Regards,

 
Posted: 03 March 2010 09:16 PM   [ Ignore ]   [ # 42 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

joytopia,

Thank you for finding the error and the fix.  I just pushed the changes to git.


Thanks!

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 03 March 2010 09:21 PM   [ Ignore ]   [ # 43 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

Sinclair,

Github’s being stupid right now but as soon as it’s back up I’ll push your file.


Thanks for the file!

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 03 March 2010 11:22 PM   [ Ignore ]   [ # 44 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-23
20 posts

Ben-

I’m finding your Ion Auth to be a great starting point for my project that handles memberships on a site. Thanks for your work…I agree that keeping it lightweight and generic is good.

Joytopia-

Would you mind sharing your create_user method and view? I’m not missing something here, right? The model has the logic to handle it, but there is not currently a method in the controller.

Thanks!

 Signature 

Famous Quotes

 
Posted: 03 March 2010 11:26 PM   [ Ignore ]   [ # 45 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

Darren,

Thanks man!

The github repo is now updated with Joytopia’s fix.


The method to use to create a user is $this->ion_auth->register().  There is an example of using it in the controller’s create_user() method.

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
3 of 88
3