Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Two auth methods in the same app?
  • Hi,

    I want to know if is possible have 2 methods (with its own users, session,..) in the same app.

    The main goal is have ORMAuth for admin (backend) panel, and SimpleAuth for frontend private area.

    Thanks in advance.
  • HarroHarro
    Accepted Answer
    Yes, that is possible, but you have to extend one of the drivers, and make some changes, because the standard driver will have collisions. For example, both use the same variables to store the login state.

    There are also some changes in the way you have to use Auth in your code, as all static calls (like Auth::login(), Auth::login(), etc) assume your app has a single login system. Instead, you'll have to forge both instances, and then use the instance in your code:

    // create the instance
    \Auth::forge('ormauth');

    // use the instance
    $auth = \Auth::instance('ormauth');
    if ($auth->login($user, $pass))
    {
        // logged in!
    }

    // you can use check
    if (\Auth::check('ormauth'))
    {
        // we have a user logged-in using Ormauth!
    }
  • Thanks Harro,

    Thats fine for me, i will try.

Howdy, Stranger!

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

In this Discussion