Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Running multiple versions of SimpleAuth
  • Not sure if this has been addressed before, I've had a look through the forums and docs but couldn't find a way to do what I'm after. Basically I was looking to have 2 versions of the simple auth running, I have no need (at present) for the more complex ones as I need to keep the admins / users seperate. It's going to be for an e-commerce site I am building so customers need to be kept separate from the admins.
    My issue is however that obviously when setting up the simple auth you have to specify the table and the fields in the config so I can set up the auth for one section(i.e. the admins) but then I'm not sure how i'd approach setting up the auth for customers. I was hoping to be able to specify a separate config or something similar then when getting an instance of auth, specify which config to work with (or something like that).
    Is this possible at all?
  • You can't have the same driver run twice, as the name of the driver is the key in the driver configuration in config/auth.php. But you fool it, very simply by creating app/classes/auth/login/mysimpleauth.php, which contains
    class Auth_Login_Mysimpleauth extends \Auth\Auth_Login_Simpleauth {}
    

    which simply creates a clone of the simpleauth class with a new driver name you can use.
  • Sweet that would work!
    The configs would then just be duplicated and renamed "mysimpleauth.php" would they not?
  • Yes, but that is not enough as you re-use the same code. So add this to your "clone":
     public static function _init()
     {
      \Config::load('mysimpleauth', true, true, true);
     }
    
    to have it load it's own config file.
  • ahhh, sweet, thanks alot! Much appreciated, loving fuel so far!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion