ollieread / multiauth

Laravel multi auth
441 stars 109 forks source link

How to use the library with custom Auth Drivers? #75

Closed Grom-S closed 9 years ago

Grom-S commented 9 years ago

Hi @ollieread I don't understand how to use the work around.. What closure are you talking about? I want to use it with this custom driver: https://github.com/TheMonkeys/laravel-google-auth Is it possible?

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.

Can you please be more specific?

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