jk215,
So you change identity to username, then try to login with username=admin and you get a login error.
Make sure the username is set in the DB. You might have to throw some debug code in ion_auth_model->login()...
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]#841 / Mar 19, 2011 12:03pm
jk215,
So you change identity to username, then try to login with username=admin and you get a login error.
Make sure the username is set in the DB. You might have to throw some debug code in ion_auth_model->login()...
#842 / Mar 21, 2011 12:33am
Hey Ben, thanks for all your work on this. Forgive me if my question is answered in one of the 83 other pages for this thread; I couldn’t find it by searching.
Do you have any plans in the works for making Ion Auth compatible with MongoDB?
#843 / Mar 21, 2011 2:22am
Kevin,
Not really, a lot of the time even if your using a nosql database you would store users in a sql db.
If you write a model for it though send me a pull request, I’m sure it would help others.
#844 / Mar 21, 2011 3:09am
I am using ion auth with sqlite3.I commented lines 549 and 884 of ion_auth_model and it worked,although i am gonna look at it later,see the auth model on sync in.I am using codeigniter 1.7.2 and PDO sqlite3 pdo driver here is the sql:
CREATE TABLE [ci_sessions] (
[session_id] VARCHAR(40) NULL PRIMARY KEY,
[ip_address] VARCHAR(16) NULL,
[user_agent] VARCHAR(50) NULL,
[last_activity] INTEGER(10) NULL,
[user_data] VARCHAR(400) NULL
);
CREATE TABLE [groups] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[name] VARCHAR(100) NULL,
[description] VARCHAR(100) NULL
);
CREATE TABLE [meta] (
[id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[user_id] INTEGER NULL,
[first_name] VARCHAR(50) NULL,
[last_name] VARCHAR(50) NULL,
[company] VARCHAR(100) NULL,
[phone] VARCHAR(20) NULL
);
CREATE TABLE [users] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[group_id] INTEGER NULL,
[ip_address] VARCHAR(40) NULL,
[username] VARCHAR(15) NULL,
[password] VARCHAR(40) NULL,
[salt] VARCHAR(40) NULL,
[email] VARCHAR(100) NULL,
[activation_code] VARCHAR(40) NULL,
[forgotten_password_code] VARCHAR(40) NULL,
[remember_code] VARCHAR(40) NULL,
[created_on] INTEGER NULL,
[last_login] INTEGER NULL,
[active] INTEGER NULL
);#845 / Mar 21, 2011 10:25am
Kevin,
Not really, a lot of the time even if your using a nosql database you would store users in a sql db.
If you write a model for it though send me a pull request, I’m sure it would help others.
Ah, thanks for the info. I’m still dipping my toes into this NoSQL thing, so I haven’t yet figured out best practices.
#846 / Mar 21, 2011 12:25pm
jk215,
So you change identity to username, then try to login with username=admin and you get a login error.
Make sure the username is set in the DB. You might have to throw some debug code in ion_auth_model->login()...
Yes that is correct. I changed the config to ‘username’ and attempted to login in the default auth/login screen. Assuming everything is at default, do I have to change anything? Am I supposed to make my own login controller/view to accommodate switching the identity? Not sure what you mean by making sure the username is set in the DB. Im trying to retrieve the default ‘administrator’ row of the DB.
Also I created a function to get user by username in the ion_auth_model and it isnt returning an object. I basically copied the get_user_by_email function verbatim. Can anyone tell me why this doesnt work?
public function get_user_by_username($username)
{
$this->db->where($this->tables['users'].'.username', $username);
$this->db->limit(1);
return $this->get_users();
}#847 / Mar 21, 2011 8:34pm
jk215,
Yes you will have to modify the controller and views to support username instead of email.
#848 / Mar 23, 2011 6:32am
Kevin,
Not really, a lot of the time even if your using a nosql database you would store users in a sql db.
If you write a model for it though send me a pull request, I’m sure it would help others.
Ah, thanks for the info. I’m still dipping my toes into this NoSQL thing, so I haven’t yet figured out best practices.
I have been looking at nosql and how one can implement it fully and its a huge undertaking by all means.I have been using cache db for hierarchical data and its kind of impressive.To add a proper nosql driver you have to figure a way to handle unstructured data and be a champion of the topic maps concept.
#849 / Mar 23, 2011 11:10am
jk215,
Yes you will have to modify the controller and views to support username instead of email.
Hi Ben
I’ve sent jk215 my modified controller/views to allow log in with username.
Looks like it’s working fine for him.
If anyone else is struggling to change from email to username please PM me and I’ll gladly let them have a copy.
Russ
#850 / Mar 23, 2011 11:11am
Thanks Russ!
#851 / Mar 23, 2011 1:02pm
Hi Ben
Just a quick question.
I want to retrieve a list of groups so I can add a drop down list to the Create User view.
I know I can get them with something like $this->ion_auth_model->get_groups(), but I seem to recall that you prefer if data was accessed via the library and not directly from the model.
Any suggestions? I don’t want to start hacking the core library.
Cheers
Russ
#852 / Mar 23, 2011 1:03pm
I cannot see register function in auth controller but there is in ion_auth library, how do i implement it ?
#853 / Mar 23, 2011 2:21pm
I cannot see register function in auth controller but there is in ion_auth library, how do i implement it ?
Hi dhaulagiri
Look at function create_user() in the sample controller (auth.php), there is an example there.
if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data, $group))
Russ
#854 / Mar 23, 2011 3:46pm
Russ,
You can use $this->ion_auth->get_groups(). The model methods are routed through the library.
#855 / Mar 23, 2011 4:25pm
Russ,
You can use $this->ion_auth->get_groups(). The model methods are routed through the library.
Thanks Ben
Looked in ion_auth.php and couldn’t see it… should have checked the user guide. Doh!
Russ