Hey Ben,
Was wondering if you could talk about what you’re doing differently from let’s say DX_Auth? And I don’t mean only in terms of features, but are you approaching the architecture/coding differently?
cheers,
Naren
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
February 10, 2010 7:00pm
Subscribe [287]#31 / Feb 28, 2010 12:20am
Hey Ben,
Was wondering if you could talk about what you’re doing differently from let’s say DX_Auth? And I don’t mean only in terms of features, but are you approaching the architecture/coding differently?
cheers,
Naren
#32 / Feb 28, 2010 5:50am
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
#33 / Mar 01, 2010 2:39pm
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));
}#34 / Mar 01, 2010 3:21pm
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!
#35 / Mar 01, 2010 6:22pm
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.
#36 / Mar 01, 2010 10:37pm
2think,
Thanks!
joytopia,
I think I’m missing something. Please describe the problem and error?
Thanks,
#37 / Mar 02, 2010 4:19am
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.
#38 / Mar 02, 2010 7:09am
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,
#39 / Mar 02, 2010 8:30am
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.
#40 / Mar 02, 2010 7:23pm
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,
#41 / Mar 02, 2010 7:31pm
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.
#42 / Mar 03, 2010 7:39pm
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(16) NOT NULL,
"username" varchar(15) NOT NULL,
"password" varchar(40) NOT NULL,
"email" varchar(40) NOT 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(20) NOT NULL,
"description" varchar(100) NOT NULL,
PRIMARY KEY("id"),
CONSTRAINT "check_id" CHECK(id >= 0)
);
INSERT INTO groups (id, name, description) VALUES
(1,'admin','Administrator'),
(2,'members','General User');
INSERT INTO meta (id, user_id, first_name, last_name, company, phone) VALUES
('1','1','Admin','istrator','ADMIN','0');
INSERT INTO users (id, group_id, ip_address, username, password, email, activation_code, forgotten_password_code, active) VALUES
('1','1','127.0.0.1','administrator','59beecdf7fc966e2f17fd8f65a4a9aeb09d4a3d4','[email protected]','',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,
#43 / Mar 03, 2010 8:16pm
joytopia,
Thank you for finding the error and the fix. I just pushed the changes to git.
Thanks!
#44 / Mar 03, 2010 8:21pm
Sinclair,
Github’s being stupid right now but as soon as it’s back up I’ll push your file.
Thanks for the file!
#45 / Mar 03, 2010 10:22pm
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!