@@ -6,12 +6,11 @@ Overriding the default configuration
6
6
7
7
For easier configuration, you can specify an array of config files to override the default plugin keys this way:
8
8
9
- config/bootstrap .php
9
+ Make sure you loaded the plugin and is using a custom config/users .php file at Application::bootstrap
10
10
```
11
11
// The following configuration setting must be set before loading the Users plugin
12
+ $this->addPlugin(\CakeDC\Users\Plugin::class);
12
13
Configure::write('Users.config', ['users']);
13
- Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);
14
- Configure::write('Users.Social.login', true); //to enable social login
15
14
```
16
15
17
16
Configuration for social login
@@ -28,13 +27,14 @@ $ composer require league/oauth1-client:@stable
28
27
29
28
NOTE: twitter uses league/oauth1-client package
30
29
31
- config/bootstrap.php
32
- ```
33
- Configure::write('OAuth.providers.facebook.options.clientId', 'YOUR APP ID');
34
- Configure::write('OAuth.providers.facebook.options.clientSecret', 'YOUR APP SECRET');
30
+ And update your config/users.php file:
35
31
36
- Configure::write('OAuth.providers.twitter.options.clientId', 'YOUR APP ID');
37
- Configure::write('OAuth.providers.twitter.options.clientSecret', 'YOUR APP SECRET');
32
+ ``` php
33
+ 'Users.Social.login' => true,
34
+ 'OAuth.providers.facebook.options.clientId' => 'YOUR APP ID',
35
+ 'OAuth.providers.facebook.options.clientSecret' => 'YOUR APP SECRET',
36
+ 'OAuth.providers.twitter.options.clientId' => 'YOUR APP ID',
37
+ 'OAuth.providers.twitter.options.clientSecret' => 'YOUR APP SECRET',
38
38
```
39
39
40
40
Or use the config override option when loading the plugin (see above)
@@ -44,15 +44,18 @@ Additionally you will see you can configure two more keys for each provider:
44
44
* linkSocialUri (default: /link-social/** provider** ),
45
45
* callbackLinkSocialUri(default: /callback-link-social/** provider** )
46
46
47
- Those keys are needed to link an existing user account to a third-party account. ** Remember to add the callback to your thrid-party app**
47
+ Those keys are needed to link an existing user account to a third-party account. ** Remember to add the callback to your thrid-party app**
48
48
49
49
Configuration for reCaptcha
50
50
---------------------
51
- ```
52
- Configure::write('Users.reCaptcha.key', 'YOUR RECAPTCHA KEY');
53
- Configure::write('Users.reCaptcha.secret', 'YOUR RECAPTCHA SECRET');
54
- Configure::write('Users.reCaptcha.registration', true); //enable on registration
55
- Configure::write('Users.reCaptcha.login', true); //enable on login
51
+ To enable reCaptcha you need to register your site at google reCaptcha console
52
+ and add this to your config/users.php file:
53
+
54
+ ``` php
55
+ 'Users.reCaptcha.key' => 'YOUR RECAPTCHA KEY',
56
+ 'Users.reCaptcha.secret' => 'YOUR RECAPTCHA SECRET',
57
+ 'Users.reCaptcha.registration' => true, //enable on registration
58
+ 'Users.reCaptcha.login' => true, //enable on login
56
59
```
57
60
58
61
@@ -70,10 +73,11 @@ and [cakephp/authorization](https://github.com/cakephp/authorization) plugins we
70
73
into their documentation for more information.
71
74
72
75
Most authentication/authorization configuration is defined at 'Auth' key, for example
73
- if you don't want the plugin to autoload the authorization service, you could do:
76
+ if you don't want the plugin to autoload the authorization service, you could add this
77
+ to your config/users.php file:
74
78
75
79
```
76
- Configure::write( 'Auth.Authorization.enable', false)
80
+ 'Auth.Authorization.enable' => false,
77
81
```
78
82
79
83
Interesting Users options and defaults
@@ -163,25 +167,17 @@ To learn more about it please check the configurations for [Authentication](Auth
163
167
164
168
You need to configure 2 things (version 9.0.4):
165
169
166
- * Change the Password identifier fields and the Authenticator for Forms configuration to let it use the email instead of the username for user identify. Add this to your Application class, right before CakeDC/Users Plugin is loaded.
170
+ * Change the Password identifier fields and the Authenticator for Forms
171
+ configuration to let it use the email instead of the username for
172
+ user identify. Add this to your config/users.php:
167
173
168
174
``` php
169
- // Load more plugins here
170
- $identifiers = Configure::read('Auth.Identifiers');
171
- $identifiers['Password']['fields']['username'] = 'email';
172
- Configure::write('Auth.Identifiers', $identifiers);
173
-
174
- $authenticators = Configure::read('Auth.Authenticators');
175
- $authenticators['Form']['fields']['username'] = 'email';
176
- Configure::write('Auth.Authenticators', $authenticators);
177
-
178
- //Configure::write('Users.config', ['users', 'permissions']);
179
-
180
- $this->addPlugin(\CakeDC\Users\Plugin::class);
175
+ 'Auth.Identifiers.Password.fields.username' => 'email',
176
+ 'Auth.Authenticators.Form.fields.username' => 'email',
181
177
```
182
178
183
- * Override the login.php template to change the Form->control to "email".
184
- Add (or copy from the [ /templates/Users/login.php] ( ../../templates/Users/login.php ) ) the file login.php to path /templates/plugin/CakeDC/Users/Users/login.php
179
+ * Override the login.php template to change the Form->control to "email".
180
+ Add (or copy from the [ /templates/Users/login.php] ( ../../templates/Users/login.php ) ) the file login.php to path /templates/plugin/CakeDC/Users/Users/login.php
185
181
and ensure it has the following content
186
182
187
183
``` php
0 commit comments