• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help choosing auth plugin

#1
[eluser]NachoF[/eluser]
Im gonna be building an app in codeigniter soon.. Ill be using Datamapper (if it makes a difference).

My app requires two kinds of roles. admins and users.. no one can register, only admins can create users or other admins (and many other actions that users cant do, of course). Thats it... which auth plugins is most appropriate?... My main concern is that most auth plugins come with the ability for people to register to a site buti dont want that... Only admins well be creating users and other admins.
thanks in advance

#2
[eluser]laytone[/eluser]
Its easiest just to write your own Auth. Look into extending your controllers with MY_Controller and implement a '_checkLogin()' function.

When you controllers extend MY_Controller(), start with the constructor and call $this->_checkLogin()

This is how the Constructors in my 'Protected' controllers look:

Code:
class Admin extends MY_Controller {
    
    public function __construct(){
        parent::__construct ();
        $this->load->model('Admin_model');
                //The next line of code makes sure I'm not trying to login and if I am not, it checks the login for usertype 'admin'
        if ($this->uri->segment(2) != 'login') $this->_check_login('admin');
        //$this->output->enable_profiler(TRUE);
    }

}

Here is an example of my /application/libraries/MY_Controller.php
Code:
class MY_Controller extends Controller {
    public function __construct() {
        parent::Controller ();
    }

    function _check_login($forwhat = 'controlpanel'){
        if ($this->session->userdata('loggedin') != TRUE){
            redirect ($forwhat.'/login');
        } else {
            if ($this->session->userdata('usertype') != $forwhat){
                $this->session->sess_destroy();
                redirect ($forwhat.'/login');
            }
        }
    }
}
This particular application has 3 types of users, controlpanel = end user, admin = the admins, and salesfloor = telemarketer login.

My controllers are the named after the user types so its easy to send the person to the correct login page (admin/login, controlpanel/login, salesfloor/login)

Its easy.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.