ErkanaAuth: A non-invasive user authentication library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: ErkanaAuth: A non-invasive user authentication library (/showthread.php?tid=3821) |
ErkanaAuth: A non-invasive user authentication library - El Forum - 10-23-2007 [eluser]Michael Wales[/eluser] I don't have the time right now to create a proper post or a Wiki article (feel free to do so for me, if you'd like) so here's a copy-paste from my blog and a link to the full article: Quote:First of all, let me be blunt about this: this is my authorization library. Of course, I will be taking user suggestions and bug fixes into account but ultimately, if it doesn’t fit within the scope of my needs, it won’t make it into the library. http://www.michaelwales.com/2007/10/erkana-codeigniter-authorization-library/ ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]imzyos[/eluser] Very Nice Gratz Small 4kbs FLEXIBLE WORKS maybe addRole function ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]Michael Wales[/eluser] Nice suggestion - I'll see about adding that soon. Although, it would be changeRole($newrole integer) - since this library only supports a single role. Nonetheless, good idea. ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]CI Lee[/eluser] Nicely done chief... I am sure this will become another commonly used tool in the stable. ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]xwero[/eluser] I will check if it's php4 compatible as soon as i can. I have one suggestion. Maybe the tablenames should be defined in a config array/file for more flexibility. It's not always possible to rename the tables. It's the first authentication library i see i will try out, keep up the good work ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]Michael Wales[/eluser] Thanks for the compliment and the suggestion xwero - that's something I had already considered, but I hate the fact of adding another file that you have to open up and change to use the library. I think I'll make a class variable to store the tables, and then a method to change those from the defaults if you wish... ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]imzyos[/eluser] Default use users and roles, but check the 2 parameter on the constructor $tables= array('usersTable' = 'users', 'rolesTable' => 'roles'); $this->load->library('Erkanaauth',$tables); ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]xwero[/eluser] My first impression - The try login snippet needs array() around the array content - what is the point of the helper functions? They are just wrappers for the library methods. Do they work when the library isn't loaded, i think not but maybe i'm wrong. So the only reason why there are helper functions is to lessen the typing? - using php4 calling the try_login method gives following error Quote:Severity: Warning I build the query and i discovered removing the limit en offset from the getwhere method did the trick. - in the getRole method why do you use and explicit join Code: $this->CI->db->select('roles.name'); Code: $this->CI->db->select('roles.name'); - I'm wondering how the class would handle content that is visible for different roles Code: <? if (getRole() == 'admin' || getRole() == 'test' || getRole() == 'test2') { ?> Maybe i'm coming on a bit too strong but i think this is good stuff so it can accept a little criticism ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]Michael Wales[/eluser] Yeah there is definitely some room for improvement - I'll come back to all of these and make a few changes in short-order. The files that I uploaded were posted as soon as I got it working, without any refactoring or really analyzing the code prior to release. ErkanaAuth: A non-invasive user authentication library - El Forum - 10-24-2007 [eluser]Michael Wales[/eluser] Quote:The try login snippet needs array() around the array content I assume you are referring to this line: Code: $query = $this->CI->db->getwhere('users', $condition, 1, 0); It doesn't need to be surrounded by array() because condition is an array. Your suggestion would make it an array, that contained an array, that included the conditions (in other words SELECT * FROM users WHERE Array() LIMIT 1,0). The helpers are there so getRole() and getField() can be used in a view - saves on typing a little. The foreach() error I am unsure about... if removing the limit and offset works, cool. Odd error nonetheless. The explicit join is just because I suck at joins and have to refer to the MySQL documentation every time. I thought about giving the implicit you mention a try but didn't test it. If it works properly, I'll probably go that route in the future. The multiple role situation is one I am aware of and I intend to correct that in the future (it will be a new method that accepts a string (or an array, I haven't decided) of user roles. If the user has one of those roles it will return TRUE. |