@@ -28,7 +28,6 @@ imports::
2828 use Authentication\AuthenticationServiceInterface;
2929 use Authentication\AuthenticationServiceProviderInterface;
3030 use Authentication\Identifier\AbstractIdentifier;
31- use Authentication\Identifier\IdentifierInterface;
3231 use Authentication\Middleware\AuthenticationMiddleware;
3332 use Cake\Http\MiddlewareQueue;
3433 use Cake\Routing\Router;
@@ -90,23 +89,20 @@ define the ``AuthenticationService`` it wants to use. Add the following method t
9089 'queryParam' => 'redirect',
9190 ]);
9291
93- // Define identifiers
9492 $fields = [
9593 AbstractIdentifier::CREDENTIAL_USERNAME => 'email',
96- AbstractIdentifier::CREDENTIAL_PASSWORD => 'password'
97- ];
98- $passwordIdentifier = [
99- 'Authentication.Password' => [
100- 'fields' => $fields,
101- ],
94+ AbstractIdentifier::CREDENTIAL_PASSWORD => 'password',
10295 ];
10396
10497 // Load the authenticators. Session should be first.
105- $service->loadAuthenticator('Authentication.Session', [
106- 'identifier' => $passwordIdentifier,
107- ]);
98+ // Session just uses session data directly as identity, no identifier needed.
99+ $service->loadAuthenticator('Authentication.Session');
108100 $service->loadAuthenticator('Authentication.Form', [
109- 'identifier' => $passwordIdentifier,
101+ 'identifier' => [
102+ 'Authentication.Password' => [
103+ 'fields' => $fields,
104+ ],
105+ ],
110106 'fields' => $fields,
111107 'loginUrl' => Router::url([
112108 'prefix' => false,
@@ -122,9 +118,9 @@ define the ``AuthenticationService`` it wants to use. Add the following method t
122118First, we configure what to do with users when they are not authenticated.
123119Next, we attach the ``Session `` and ``Form `` :doc: `/authenticators ` which define the
124120mechanisms that our application will use to authenticate users. ``Session `` enables us to identify
125- users based on data in the session while `` Form `` enables us
126- to handle a login form at the ``loginUrl ``. Finally we attach an :doc: ` identifier
127- </identifiers>` to convert the credentials users will give us into an
121+ users based on data in the session - it uses the session data directly as identity without any
122+ database lookup. `` Form `` enables us to handle a login form at the ``loginUrl `` and uses an
123+ :doc: ` identifier </identifiers >` to convert the credentials users will give us into an
128124:doc: `identity </identity-object >` which represents our logged in user.
129125
130126If one of the configured authenticators was able to validate the credentials,
0 commit comments