diff --git a/docs/en/tutorials-and-examples/cms/authentication.md b/docs/en/tutorials-and-examples/cms/authentication.md index 7ed981f752..eb53cd73c5 100644 --- a/docs/en/tutorials-and-examples/cms/authentication.md +++ b/docs/en/tutorials-and-examples/cms/authentication.md @@ -45,7 +45,7 @@ Because we want to hash the password each time it is set, we'll use a mutator/se CakePHP will call a convention based setter method any time a property is set in one of your entities. Let's add a setter for the password in **src/Model/Entity/User.php**: -```php {3,12-18} +```php {4,12-18} 'email', - AbstractIdentifier::CREDENTIAL_PASSWORD => 'password', + PasswordIdentifier::CREDENTIAL_USERNAME => 'email', + PasswordIdentifier::CREDENTIAL_PASSWORD => 'password', ]; // Load the authenticators. Session should be first. @@ -175,9 +175,8 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe 'action' => 'login', ], 'identifier' => [ - 'Authentication.Password' => [ - 'fields' => $fields, - ], + 'className' => 'Authentication.Password', + 'fields' => $fields, ], ]); @@ -185,8 +184,6 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe } ``` -::: - ### Configuring the AppController In your `AppController` class add the following code: @@ -232,9 +229,8 @@ If you visit your site, you'll get an "infinite redirect loop" so let's fix that In your `UsersController`, add the following code: -::: code-group - -```php [UsersController.php] +```php +// src/Controller/UsersController.php public function beforeFilter(\Cake\Event\EventInterface $event): void { parent::beforeFilter($event); @@ -260,7 +256,10 @@ public function login() } ``` -```php [templates/Users/login.php] +Next, add the template for your login action: + +```php +