Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 5.2 - Error retrieving Eloquent Model in AuthServiceProvider from config #2

Open
bandgeekndb opened this issue May 3, 2016 · 0 comments

Comments

@bandgeekndb
Copy link

I'm trying to implement this package in the latest Laravel framework and I'm running into an issue. This is the current code for retrieving parameters from the configuration, as part of the AuthServiceProvider class in this package:

private static function createEloquentLdapProvider($app)
    {
        $config = $app['config'];

        $ldap = $config['auth.ldap'];
        $model = $config['auth.model'];

        return new EloquentLdapUserProvider($ldap, $app['hash'], $model);
    }

In Laravel 5.2, they have moved some of the settings around, and the model setting is no longer accessible via auth.model. An example of the providers array from Laravel 5.2, customized for use with this package, is shown below:

'providers' => [
        'users' => [
            'driver' => 'eloquentLdapCredentials',
            'model' => \App\Employee::class,
        ],
    ],

As a result of this change, when Laravel attempts the retrieveByCredentials() method on the EloquentUserProvider class, it calls the createModel() method, which fails since the $model variable that was passed in is null (since it was read incorrectly from the config).

I can change the path to the model config entry, but since providers can be added/removed, this particular fix only works if you use the default users provider:

$model = $config['auth.providers.users.model'];

I assume a proper fix would be getting the active provider and then reading the model from the array that way, but I'm not familiar enough with the code to submit that as a pull request, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant