Subhan
Subhan

Reputation: 1634

Cakedc Users Could not load configuration file

I'm using CakeDC's Users Plugin for authentication. I've followed all the steps of installation as documented here, but i'm getting this error:

enter image description here

I've performed the following steps:

  1. composer require cakedc/users
  2. composer require league/oauth2-facebook:@stable
  3. composer require league/oauth2-google:@stable
  4. bin/cake migrations migrate -p CakeDC/Users
  5. In config/bootstrap.php
    Configure::write('Users.config', ['users']);
    Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true ]);
    Configure::write('Users.Social.login', true); //to enable social login
  1. Load the Component in your src/Controller/AppController.php, and use the passed Component configuration to customize the Users Plugin:

    $this->loadComponent('CakeDC/Users.UsersAuth');
    

Update: I've removed

Configure::write('Users.config', ['users']);

this line from my bootstrap as i'm using the default users.php file which is present inside the plugin now. But i get this error now:

Invalid provider or missing class (League\OAuth2\Client\Provider\LinkedIn)

I can get rid of this error by disabling social login (which is not what i want to do):

Configure::write('Users.Social.login', false);

After disabling the social login i get this error:

Error: A route matching "array ( 'plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login', 'prefix' => false, '_ext' => NULL, )" could not be found.

Any help would save my day.

Upvotes: 1

Views: 2700

Answers (2)

ConquestXD
ConquestXD

Reputation: 754

@ndm was right, Step 5 is for Configuration, when installing with composer removing the following 2 lines fixes the error before the Migration Step:

Configure::write('Users.config', ['users']);
Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true ]);

Then after the migration add these lines back in to continue the installation.

Upvotes: 2

ndm
ndm

Reputation: 60463

Step number 5 is customization - check the header in the docs that you've linked. So that's not actually a required installation step.

The problem should be rather easy to figure from the naming, the error that you're encountering, and the stacktrace (just check what's being done in each of the frames) - setting Users.config is to be used to define custom config files, the one you've defined doesn't exist (or isn't reabable), hence the error.

collection((array)Configure::read('Users.config'))->each(function ($file) {
    Configure::load($file);
});

https://github.com/CakeDC/users/blob/3.2.0/config/bootstrap.php#L21-L23

So either don't do that and define the configuration elsewhere (being it in your app config, or wherever), or create the missing users.php config file and put your users plugin configuration in there.

See also

https://github.com/CakeDC/users/.../Configuration.md#overriding-the-default-configuration

Upvotes: 0

Related Questions