File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44namespace Authentication \Authenticator ;
55
66use ArrayAccess ;
7+ use Authentication \Identifier \IdentifierInterface ;
78use Cake \Http \Exception \UnauthorizedException ;
89use Psr \Http \Message \ResponseInterface ;
910use Psr \Http \Message \ServerRequestInterface ;
1314 */
1415class PrimaryKeySessionAuthenticator extends SessionAuthenticator
1516{
17+ /**
18+ * @param \Authentication\Identifier\IdentifierInterface $identifier
19+ * @param array<string, mixed> $config
20+ */
21+ public function __construct (IdentifierInterface $ identifier , array $ config = []) {
22+ $ config += [
23+ 'identifierKey ' => 'id ' ,
24+ ];
25+
26+ parent ::__construct ($ identifier , $ config );
27+ }
28+
1629 /**
1730 * Authenticate a user using session data.
1831 *
@@ -30,7 +43,7 @@ public function authenticate(ServerRequestInterface $request): ResultInterface
3043 return new Result (null , Result::FAILURE_IDENTITY_NOT_FOUND );
3144 }
3245
33- $ user = $ this ->_identifier ->identify ([' id ' => $ userId ]);
46+ $ user = $ this ->_identifier ->identify ([$ this -> getConfig ( ' identifierKey ' ) => $ userId ]);
3447 if (!$ user ) {
3548 return new Result (null , Result::FAILURE_IDENTITY_NOT_FOUND );
3649 }
You can’t perform that action at this time.
0 commit comments