Welcome Guest, Not a member yet? Register   Sign In
The Auth Library 1.0.3 - The Easiest Auth Library for CodeIgniter
#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


Messages In This Thread
The Auth Library 1.0.3 - The Easiest Auth Library for CodeIgniter - by El Forum - 03-25-2009, 02:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB