Thank you! all is because of the __call() in ion_auth class.
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]#1231 / Jul 08, 2012 3:52am
Thank you! all is because of the __call() in ion_auth class.
#1232 / Jul 09, 2012 8:46am
I’ve been using the Ion Auth library for the first time on a new project I’m working on. I thought I’d post a couple of questions / observations I’ve noted, although I should preface this with the following disclaimers:
1. It’s a great library and I’m truly grateful for the time and effort that’s been put in by others, that I freely used.
2. These are only my views, and I’m generally held to be a bit of an idiot. Your Mileage May Vary.
3. Please excuse the pedantry.
ion_auth->groups() - the documentation says it returns array of objects: it actually returns the query object, same as the other listing functions. Usage note should probably reflect this:
ion_auth->groups()->result();
ion_auth->is_admin() and ion_auth->in_group() only work for the logged-in user. Surely these should take an optional user object or ID? It’d be useful if they did, in any case.
User editing - The update() function is there, via the model* - but there’s no edit view/controller. I appreciate this is primarily an auth library, but it’s got views for everything except editing your account details. Seems an odd ommision.
Views - the supplied views contain contain unnecessary markup. What’s the point of leaving that “mainInfo” and “pageTitleBorder” stuff in there?
User fields - I appreciate that they’re common fields, but I don’t think the library by default should manage any more user data than that which it requires to function. Stuff like concatenating phone numbers, storing a company name - those are application-specific considerations that should be outside the scope of the default library implementation.
* Controller/Model functions: If the function isn’t defined in the controller, pass it off to the model? This seems a very odd thing to do. Is it a common pattern? What’s the rationale? Makes it harder to know where to find the function you’re looking for.
#1233 / Jul 09, 2012 9:12am
w1nternut3, some of those points are good suggestions. Why not open a few issues on the github repo? That way, people who matter will quickly notice these things…
#1234 / Jul 09, 2012 11:28am
Thanks - I wasn’t sure whether the forum or github would be the the most appropriate place to put them - they’re not really “bugs”, they may well just be a result of my poor understanding of the library. Nevertheless, I’ve added some issues to github for extra visibility.
#1235 / Jul 09, 2012 2:35pm
I’m not sure if there is a built in way to do this, but is it possible to look up the ID of a user you are creating from a different account? I have my teacher data and my student data separate from the user data table, so when I create their accounts, I need to create their rows in those extra tables as well. I created those extra data tables by using the auto-incrementing ID from the users table, so when I create a new user it’s the only piece of information that I don’t supply ion_auth for registration. Should I create a new function to look up the id based off of the other user’s data or is there something built in for that?
#1236 / Jul 09, 2012 11:08pm
I’m not sure if there is a built in way to do this, but is it possible to look up the ID of a user you are creating from a different account? I have my teacher data and my student data separate from the user data table, so when I create their accounts, I need to create their rows in those extra tables as well. I created those extra data tables by using the auto-incrementing ID from the users table, so when I create a new user it’s the only piece of information that I don’t supply ion_auth for registration. Should I create a new function to look up the id based off of the other user’s data or is there something built in for that?
`ion_auth->register()` returns the ID of the user just created. I think that can solve your current problem.
I don’t think there’s a built-in way to access the ID of a user based off of a random column from their user-data. Looks like you will need to write something custom for it if you need…
#1237 / Jul 10, 2012 5:27pm
User editing - The update() function is there, via the model* - but there’s no edit view/controller. I appreciate this is primarily an auth library, but it’s got views for everything except editing your account details. Seems an odd ommision.
I agree it could be very helpfull, i wrote my custom method and shared it in the forum but i think it could be included in the lib.
User fields - I appreciate that they’re common fields, but I don’t think the library by default should manage any more user data than that which it requires to function. Stuff like concatenating phone numbers, storing a company name - those are application-specific considerations that should be outside the scope of the default library implementation.
maybe you are right even if I often use structure and phone in my forms. But as I use phone in a unique field i have to replace the 3 fields related code at startup. so what would be better : removing existing code or writing new code ? xD
* Controller/Model functions: If the function isn’t defined in the controller, pass it off to the model? This seems a very odd thing to do. Is it a common pattern? What’s the rationale? Makes it harder to know where to find the function you’re looking for.
I never had really noticed about that but i better understand some behaviors now 😉
I would add to the list :
* some unstranslated strings/strings not using lang files available translations. (some fields names like “password”, or strings like “type again the password” or similar, if i remember, there are a few other in the views)
I already changed this for myself, i would have done it on github but i’m not really used of the system and how it works :(
As you already mentionned these are just small potatoes compared to the what offers ion_auth and the good work on it
Thanx for it 😊
As i just mentionned here are the untranslated strings i found if someone want to fix it on github
L55 $this->form_validation->set_rules(‘identity’, ‘Identité’, ‘required’);
L56 $this->form_validation->set_rules(‘password’, ‘Mot de passe’, ‘required’);
L110 $this->form_validation->set_rules(‘old’, ‘Old password’, ‘required’);
L111/L218 $this->form_validation->set_rules(‘new’, ‘New Password’,
L112/L219 $this->form_validation->set_rules(‘new_confirm’, ‘Confirm New Password’,
L176 $this->form_validation->set_rules(‘email’, ‘Email Address’, ‘required’);
315 $this->form_validation->set_rules(‘confirm’, ‘confirmation’, ‘required’);
316 $this->form_validation->set_rules(‘id’, ‘user ID’, ‘required|alpha_numeric’);
362 $this->form_validation->set_rules(‘first_name’, ‘First Name’, ‘required|xss_clean’);
$this->form_validation->set_rules(‘last_name’, ‘Last Name’, ‘required|xss_clean’);
$this->form_validation->set_rules(‘email’, ‘Email Address’, ‘required|valid_email’);
$this->form_validation->set_rules(‘phone1’, ‘First Part of Phone’, ‘required|xss_clean|min_length[3]|max_length[3]’);
$this->form_validation->set_rules(‘phone2’, ‘Second Part of Phone’, ‘required|xss_clean|min_length[3]|max_length[3]’);
$this->form_validation->set_rules(‘phone3’, ‘Third Part of Phone’, ‘required|xss_clean|min_length[4]|max_length[4]’);
$this->form_validation->set_rules(‘company’, ‘Company Name’, ‘required|xss_clean’);
$this->form_validation->set_rules(‘password’, ‘Password’, ‘required|min_length[’ . $this->config->item(‘min_password_length’, ‘ion_auth’) . ‘]|max_length[’ . $this->config->item(‘max_password_length’, ‘ion_auth’) . ‘]|matches[password_confirm]’);
369 $this->form_validation->set_rules(‘password_confirm’, ‘Password Confirmation’, ‘required’);
386 $this->session->set_flashdata(‘message’, “User Created”);
+ views texts
#1238 / Jul 16, 2012 1:26pm
Thanks w1ntermut3, I received the Github issues and will get to them as soon as I can.
Here are my replies to your post:
ion_auth->groups() - the documentation says it returns array of objects: it actually returns the query object, same as the other listing functions. Usage note should probably reflect this:
ion_auth->groups()->result();
Yep, the docs definitely need to be updated for this, if you could send a pull request on github for things like this that you find it would be very helpful.
ion_auth->is_admin() and ion_auth->in_group() only work for the logged-in user. Surely these should take an optional user object or ID? It’d be useful if they did, in any case.
This already existed for in_group but is not documented I add this to is_admin() and documented for both methods. Thanks!
User editing - The update() function is there, via the model* - but there’s no edit view/controller. I appreciate this is primarily an auth library, but it’s got views for everything except editing your account details. Seems an odd ommision.
Very true and something we need to add. Send a pull request if you can or I’ll add it when I get a chance.
Views - the supplied views contain contain unnecessary markup. What’s the point of leaving that “mainInfo” and “pageTitleBorder” stuff in there?
The views are very basic code I pulled out of another project. I just pushed a commit to clean them up a bit.
User fields - I appreciate that they’re common fields, but I don’t think the library by default should manage any more user data than that which it requires to function. Stuff like concatenating phone numbers, storing a company name - those are application-specific considerations that should be outside the scope of the default library implementation.
I get what your saying but I have them in there because they are very common and they are a good example of how to add fields. You’d be surprised how many times a week I have to help someone add fields and this gives them a very quick reference.
* Controller/Model functions: If the function isn’t defined in the controller, pass it off to the model? This seems a very odd thing to do. Is it a common pattern? What’s the rationale? Makes it harder to know where to find the function you’re looking for.
The controller methods aren’t passed to the model, just the library methods. It’s not all that common in CI code but it gives you a very clean way to keep the data specific methods separated in the model and gives you the ability to extend the model methods using the library.
Thanks for all the great feeback!
#1239 / Jul 16, 2012 1:27pm
rip_pit,
Please send a pull request for any additional translations that are needed. Thanks!
#1240 / Jul 17, 2012 7:53am
Hi, I’m now trying to use Ion Auth but when I’m running the sql scripts of Ion auth to make tables on my database it shows me an error:
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IDENTITY(1,1),
ip_address varbinary(16) NOT NULL,
username varchar(100) ’ at line 2
How can I fix this? Nwei I’m using xampp server in windows 7 64-bit
#1241 / Jul 17, 2012 8:14am
Hi, Its now working. I used the ion_auth.sql file 😊 Nwei how can I make the username to be used as the identity for logging in instead of email address? Because I tried registering same username but different email address and it registers the account in the database but it adds a number at the end of the username. Like admin, admin1, admin2 etc… I want to make the username field unique and I want it to be used when logging in instead of the email address. Thanks in advance for ur replies/suggestions 😊
#1242 / Jul 17, 2012 9:32am
Hey rei,
Just change the ‘identity’ config setting to ‘username’ in the ion_auth.php config file.
#1243 / Jul 17, 2012 10:51am
Thanks for your quick reply sir. It’s now working 😊 Your Ion Auth library is awesome 😊 Thanks for your hard work in making this library, this will save me a lot of time 😊 I just want to ask whats the “users_groups” table for??? Because I tried registering an account and it adds record in those tables but I dont know whats the use of that table. And can I add custom fields for registering an account? Like adding fields for address, cellphone number etc.. Please tell me if its provided by the library or I need to edit the source code of the library to suit my needs.
#1244 / Jul 17, 2012 10:56am
Users are assigned to groups, the users_groups table holds those relations.
To add new data just add the fields to the users table and then you can pass it into the register() or update() methods.
Thanks!
#1245 / Jul 17, 2012 11:04am
Wow. So I can really add custom fields without editing the source code of the Ion Auth library. Awesome! Thanks again sir 😊