Welcome Guest, Not a member yet? Register   Sign In
Ion Auth - Lightweight Auth System based on Redux Auth 2

[eluser]Kostya1111[/eluser]
Hi all,

I've read previous comments but my questions have not disappeared.

I watch in source code of library and don't understand why it works:
Code:
$this->ion_auth->users()->result();

It is string from sample controller auth.php

In src file of library is not method users();. Where is it?
why methods are not in the file application/library/ion_auth.php?
What is a magic autoload?

Thanks

[eluser]adityamenon[/eluser]
[quote author="Kostya1111" date="1341727925"]
What is a magic autoload?
[/quote]

Magic Autoload : http://php.net/manual/en/language.oop5.autoload.php

The methods are in application/models/ion_auth_model.php - which is why you need to call ->result() on those functions just like any normal Codeigniter ActiveRecord objects.

[eluser]Kostya1111[/eluser]
Thank you! all is because of the __call() in ion_auth class.

[eluser]w1ntermut3[/eluser]
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.

[eluser]adityamenon[/eluser]
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...

[eluser]w1ntermut3[/eluser]
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.

[eluser]digital_frog[/eluser]
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?

[eluser]adityamenon[/eluser]
Quote: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...

[eluser]rip_pit[/eluser]
[quote author="w1ntermut3" date="1341838019"]

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.
[/quote]
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.

[quote author="w1ntermut3" date="1341838019"]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.[/quote] 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

[quote author="w1ntermut3" date="1341838019"]
* 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.[/quote]
I never had really noticed about that but i better understand some behaviors now Wink

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 Sad


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 Smile


As i just mentionned here are the untranslated strings i found if someone want to fix it on github
Quote: 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

[eluser]Ben Edmunds[/eluser]
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!




Theme © iAndrew 2016 - Forum software by © MyBB