ErkanaAuth: A non-invasive user authentication library |
[eluser]tomcode[/eluser]
I understand that point. I just have this shortcut in my head : CodeIgniter ? data base ? => model.
[eluser]BrandonDurham[/eluser]
So do you make your above code a library and autoload it?
[eluser]Michael Wales[/eluser]
Quote:So do you make your above code a library and autoload it?Yes.
[eluser]flosaurus[/eluser]
[quote author="Michael Wales" date="1200265545"] get_user() is a bit different than what we've seen in the past. I usually extend my Controller class, having all of my classes assign the return value to a variable I can us within my view (for echoing out user info, as needed). For any controllers needing Authorization - I make a valid get_user() return value a requirement. application/libraries/MY_Controller.php Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); I'm quite new to CI and would like to know how to use your librarie MY_Controller.php to secure a controler. Could you provide some example ? thanks a lot
[eluser]fakeempire[/eluser]
http://www.michaelwales.com -- seems to be down and all download links point to that. Does someone have it mirrored somewhere? Thanks
[eluser]Michael Wales[/eluser]
Quote:I’m quite new to CI and would like to know how to use your librarie MY_Controller.php to secure a controler. Could you provide some example ? Sure thing: /application/libraries/MY_Controller.php This code will create two classes that extends the Controller class. The first class is Public_Controller and allows anyone to access your site. The currently logged in user information is available in your controller as $this->data->user and within your view as $user (if you pass the $this->data object to your view). The second class is Admin_Controller and only allows a logged in user to access it. It will redirect to the default controller if a user is not logged in. Code: class Public_Controller extends Controller { Example Controller Code: // Only a logged in user can access the methods within this class Code: // Anyone can access the methods within this class, but you still have access to user information. Finally - our view: showing off our user's display name: Code: Welcome, <?= $user->display_name; ?>.
[eluser]tomcode[/eluser]
@Michel: Doesn't he need to include the Public_Controller/Admin_Controller ? Genre : Code: include 'Admin_Controller' .EXT;
[eluser]Kemik[/eluser]
Hello, What's the benefit of putting that code in MY_Controller? I usually make a function in the controller (e.g. function security, function got_permission, etc) and then call that. I've checked the userguide as I think I've seen MY_ stuff used before but the page below doesn't go in to much detail. http://ellislab.com/codeigniter/user-gui...aries.html Edit: This question may be better for a separate thread.
[eluser]tomcode[/eluser]
Quote:What’s the benefit of putting that code ...It becomes reusable for several controllers |
Welcome Guest, Not a member yet? Register Sign In |