ollieread / multiauth

Laravel multi auth
441 stars 109 forks source link

Custom Auth Example? #77

Closed notflip closed 9 years ago

notflip commented 9 years ago

Hi! I don't quite understand the following

At this current moment in time, custom Auth drivers written for the base Auth class will not work. I'm currently looking into this particular issue but for the meantime, you can work around this by changing your closure to return an instance of Ollieread\Multiauth\Guard instead of the default.

Where do I need to return the ollieread version of the guard? Thank you!

SimonHFL commented 9 years ago

try this:

Auth::XXXX()->extend('name of driver', function() { $provider = App::make('namespace\of\custom\provider'); return new Ollieread\Multiauth\Guard($provider, App::make('session.store')); });

If you look at this guide to extending to a custom driver, you can see that they return new Illuminate\Auth\Guard - so I believe that is what he is referring to as the default that you have to switch out with Ollieread\Multiauth\Guard http://toddish.co.uk/blog/creating-a-custom-laravel-4-auth-driver/

SimonHFL commented 9 years ago

Actually I forgot the name parameter. So instead it is something like this:

Auth::XXXX()->extend('name of driver', function() { $provider = App::make('namespace\of\custom\provider'); return new Ollieread\Multiauth\Guard($provider, App::make('session.store'), 'XXXX'); });

You can read this thread for more explanation https://github.com/ollieread/multiauth/pull/26

notflip commented 9 years ago

Will give this a try today! Thank you