Skip to content

setConfig overrides constructor. #115

@mathieutu

Description

@mathieutu

Hi,
as you can see in the following lines, the config is passed twice. Firstly to the constructor of the provider, and then with a setConfig method.

protected function buildOAuth2Provider(SocialiteManager $socialite, $providerClass, $providerName)
{
$this->classExtends($providerClass, \Laravel\Socialite\Two\AbstractProvider::class);
$config = $this->getConfig($providerClass, $providerName);
$provider = $socialite->buildProvider($providerClass, $config->get());
$provider->setConfig($config);
return $provider;
}

The setConfig method is just about filling the config with the passed parameters, and so, totally overriding the previous work from builProvider and provider constructor (which could be overridden by the dev)

public function setConfig(ConfigInterface $config)
{
$config = $config->get();
$this->config = $config;
$this->clientId = $config['client_id'];
$this->clientSecret = $config['client_secret'];
$this->redirectUrl = $config['redirect'];
return $this;
}

It can for example lead to this issue: #110
(actually, I've found that problem, because I had the same)

In my opinion we have to purely and simply remove the re-setting of attributes in setConfig.

I can make a quick PR to do that if you want.

Matt'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions