Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Error with custom UserProvider #24

Open
Biptaste opened this issue Feb 22, 2016 · 2 comments
Open

Error with custom UserProvider #24

Biptaste opened this issue Feb 22, 2016 · 2 comments

Comments

@Biptaste
Copy link

Hi,

I tried to use your package with a custom UserProvider

Argument 1 passed to Kbwebs\MultiAuth\Guard::__construct() must implement interface Illuminate\Contracts\Auth\UserProvider, instance of Illuminate\Auth\Guard given

in Guard->__construct(object(Guard), object(Store), 'user') in AuthManager.php line 47

I registered my UserProvider as written in Laravel's doc (I use Laravel 5.1)

Auth::user()->extend('user', function($app) {
    return $this->app->make(\App\Auth\UserProvider::class);
});

Actually I wrote a dirty fix, I registered my provider like that.

Auth::user()->extend('user', function($app) {
    return new \Kbwebs\MultiAuth\Guard($app->make(\App\Auth\UserProvider::class), $app['session.store'], 'user');
});
@tanner0101
Copy link

I'm also experiencing this issue.

@dorianneto
Copy link

Hi guys,

I tried to create a custom EloquentUserProvider about your package and I also had the same problem. I searched for the problem and after some time, I realized that the method callCustomCreator in Kbwebs\MultiAuth\AuthManager class return a Guard type instead of a Provider type.

To resolve this issue, I chained a method getProvider() to return to be a Provider type.

/**
 * Call a custom driver creator.
 * @param  string  $driver
 * @return \Kbwebs\MultiAuth\Guard
 */
protected function callCustomCreator($driver)
{
    $custom = parent::callCustomCreator($driver)->getProvider(); <--------
    if($custom instanceof Guard) {
        return $custom;
    }
    return new Guard($custom, $this->app['session.store'], $this->name);
}

I have not tested to custom DatabaseProvider, that is why I have not sent a PR.

I hope that help.

dorianneto added a commit to dorianneto/MultiAuth that referenced this issue May 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants