@@ -45,7 +45,7 @@ Because we want to hash the password each time it is set, we'll use a mutator/se
4545CakePHP will call a convention based setter method any time a property is set in one of your
4646entities. Let's add a setter for the password in ** src/Model/Entity/User.php** :
4747
48- ``` php {3 ,12-18}
48+ ``` php {4 ,12-18}
4949<?php
5050namespace App\Model\Entity;
5151
@@ -109,7 +109,7 @@ In **src/Application.php**, add the following imports:
109109use Authentication\AuthenticationService;
110110use Authentication\AuthenticationServiceInterface;
111111use Authentication\AuthenticationServiceProviderInterface;
112- use Authentication\Identifier\AbstractIdentifier ;
112+ use Authentication\Identifier\PasswordIdentifier ;
113113use Authentication\Middleware\AuthenticationMiddleware;
114114use Psr\Http\Message\ServerRequestInterface;
115115```
@@ -123,11 +123,9 @@ class Application extends BaseApplication
123123{
124124```
125125
126- Then add the following methods :
126+ Then add the following to your ` middleware() ` method :
127127
128- ::: code-group
129-
130- ``` php [middleware()]
128+ ``` php
131129// src/Application.php
132130public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
133131{
@@ -142,7 +140,9 @@ public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
142140}
143141```
144142
145- ``` php [getAuthenticationService()]
143+ Next, add the ` getAuthenticationService() ` method:
144+
145+ ``` php
146146// src/Application.php
147147public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
148148{
@@ -160,8 +160,8 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe
160160 ]);
161161
162162 $fields = [
163- AbstractIdentifier ::CREDENTIAL_USERNAME => 'email',
164- AbstractIdentifier ::CREDENTIAL_PASSWORD => 'password',
163+ PasswordIdentifier ::CREDENTIAL_USERNAME => 'email',
164+ PasswordIdentifier ::CREDENTIAL_PASSWORD => 'password',
165165 ];
166166
167167 // Load the authenticators. Session should be first.
@@ -175,18 +175,15 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe
175175 'action' => 'login',
176176 ],
177177 'identifier' => [
178- 'Authentication.Password' => [
179- 'fields' => $fields,
180- ],
178+ 'className' => 'Authentication.Password',
179+ 'fields' => $fields,
181180 ],
182181 ]);
183182
184183 return $service;
185184}
186185```
187186
188- :::
189-
190187### Configuring the AppController
191188
192189In your ` AppController ` class add the following code:
0 commit comments