Welcome Guest, Not a member yet? Register   Sign In
The Auth Library 1.0.3 - The Easiest Auth Library for CodeIgniter
#41

[eluser]Christophe-France[/eluser]
Thank you for the fast reply. I made the change.
Sorry, I'm beginning with Ci and Auth.

Chris
#42

[eluser]Bionicmaster[/eluser]
Hi, I have some suggestions for better functionality on this great app:

1) <code>$this->CI->lang->load('auth', 'english');</code> can be <code>$this->CI->lang->load('auth', $this->config->item('language'));</code> to load predefined user language, previous translate of the language file.

2) in login attempts, you can use a $config variable instead of 5, more user configurable.

3) same case with view's routes (default 'auth') and name of db tables.

4) using Active Record for some querys, for using CI styles: <code>$this->CI->db->query("SELECT * FROM `users` WHERE `username` = '$username'");</code> can be <code>$this-CI->db->where('username', $username)->get('users'); </code>

sorry if this is wrong and for my bad english Sad
#43

[eluser]Adam Griffiths[/eluser]
[quote author="Bionicmaster" date="1237331018"]Hi, I have some suggestions for better functionality on this great app:

1) <code>$this->CI->lang->load('auth', 'english');</code> can be <code>$this->CI->lang->load('auth', $this->config->item('language'));</code> to load predefined user language, previous translate of the language file.

2) in login attempts, you can use a $config variable instead of 5, more user configurable.

3) same case with view's routes (default 'auth') and name of db tables.

4) using Active Record for some querys, for using CI styles: <code>$this->CI->db->query("SELECT * FROM `users` WHERE `username` = '$username'");</code> can be <code>$this-CI->db->where('username', $username)->get('users'); </code>

sorry if this is wrong and for my bad english Sad[/quote]

Thanks for the input, I'll see about implementing them. In regards to using the Active Record library, I purposefully didn;t use it because of speed, I wanted the queries to run quickly as possible, hence why I used straight queries.

Thanks.
#44

[eluser]Bionicmaster[/eluser]
another special question, Why do you use var_dump in functions? sorry for my ignorance Sad
#45

[eluser]Adam Griffiths[/eluser]
[quote author="Bionicmaster" date="1237334849"]another special question, Why do you use var_dump in functions? sorry for my ignorance Sad[/quote]

Damn, that was there whilst I was debugging. I was sure I took that out, anyways it will be removed in 1.0.3.

Thanks.
#46

[eluser]Bionicmaster[/eluser]
Another comments, in _verify_cookie, you can use $userdata->row or $userdata->row_array() instead of result_array(), simplifying your indentifier in $identifier = $result->username . $result->token or $result['username'] . $result['token'], and is quickly code too.
#47

[eluser]PoetaWD[/eluser]
Hello,

just started playing around with code igniter today...

found your library and said... why not ???

Well... the first try gave me and error:

Parse error: parse error in C:\wamp\www\ci-sge\system\application\libraries\Auth.php on line 91

Any ideas on how to fix it ?

Thanks
#48

[eluser]Christophe-France[/eluser]
the problem is in the application/libraries/Auth file :

if($single == TRUE && $user_level == $level)
{
return TRUE;
}
else
{
show_error($this->CI->lang->line('insufficient_privs'));
}
elseif($user_level <= $level)
{
return TRUE;
}
else
{
show_error($this->CI->lang->line('insufficient_privs'));
}

Just remove the first "else" condition, and it should work ;o)
#49

[eluser]SSgt Dodger USMC[/eluser]
Hi Adam!

First I want to thank you for making this library! It is exactly the simple solution I was looking for.

I have read the user guide, and I still have some general questions about the use of each file once implemented and installed. If you (or any of the hundreds of people here smarter than me) can confirm or deny my logic here, I would greatly appreciate the sanity check.

-config/auth.php - This file sets the configuration details for the library as clearly outlined in the documentation... I get this.

-controllers/admin.php - this file sets the 'example' code up to show users how to use the functions. Got it.
---My question is about extending the class to Applications. When I change the code in any other function from 'extends controller' to 'extends application' what am I really telling it? I understand that it looks in libraries/MY_Controller.php in order to support form validation (and I very loosely understand what that means...), but what am I getting from changing that? Am I losing anything by NOT extending controllers? Do I have to change this in every controller in order to use this library?

-libraries/auth.php - This is where the core functionality is defined for library. The restrict, login, logout, register, and logged_in functions are setup here. So, if I want to change the the logic of those features, I do it here. I am also assuming that any function with an underscore is used internally and shouldn't be called from other controllers.
---question: What does the Auth() function specifically do and how is it called?

-libraries/MY_Controller.php - This is the file that confuses me the most. Does this file define the 'application' from the 'extends application' portion of my controllers? Is this file optional? Can it (and should it) be renamed? There are login, logout, and redirect functions here as well, but since they point to the libraries/auth.php, why are they here? how do they differ from those in libraries/auth.php? Are the other functions in here to be used internally only? I am really confused by the functionality of this file.

-views/*.php - these are the user front end to the library. I use the functionality of this library inside of a view template, so I removed everything except the contents of the container div. I noticed that the form tag here has no action... and, for example, when I first placed the login form into my page, it did nothing when I click the login button. I added action='' to the form tag and all was well, but I have no clue why.

I now have this library working in my application, and it works well, but I want a much clearer understanding of this library before I move on with the project. If you need code examples I can provide them as well.

Again Adam, excellent work, and thanks in advance for any help and general enlightenment you all can provide!
#50

[eluser]Adam Griffiths[/eluser]
Hey, thanks for using the library.

controllers/admin.php - yes this is just an example controller...your queries about the Application controller have been answered below. The only places you need to use "extends Application" in place of "extends Controller" is when you need to use The Authentication Library, I would still recommend using "extends Application" instead anyway, just in case your app might need extras built on afterwards.

libraries/auth.php is the main library file. If you wanted to change anything in the library, you would do it here. So you're logic is correct. Yes the functions that begin with an underscore are only meant for internal use by the library. The Auth() function is the constructor, much like __construct() - just the PHP4 constructor; this also works for PHP5. Since CI supports both PHP4 and PHP5, I thought it was best to keep supporting both versions.

libraries/MY_Controller.php is an extended Controller. Just like any other Controller you'd have in your application, I just added it into a library. So yes, this is where the "extends Application" comes from. This file is not optional, it is needed to properly process the forms. It can be renamed, but then you'd have to use the new name in your controllers, and if I were to update that file in a later version of The Authentication Library then you'd have to change it when updating.

The functions for login, logout and register are there purely for convenience, they call upon the functions inside the auth.php library because that's how you reference the library. If I were to extend the Auth class instead of Controller, you wouldn't need to use $this->auth->login(); - but then you wouldn't have any usual Controller functions, like the $this->class->function(); syntax. This is exactly how you would use the functions in a normal controller, the only difference is that you extend this controller to get all the functionality inside it. The whole point behind having this file is because the form validation library only allows custom callbacks in controllers, so I created this file as a way around it. The functions in there can all be overridden by having a function of your own in your controller of the same name, this way you can change any way the library checks data.


With this post I'd also like to mention that Version 1.0.3 has now been released. This fixes a couple of bugs everybody had. http://programmersvoice.com/codeigniter/...ibrary-103




Theme © iAndrew 2016 - Forum software by © MyBB