Skip to content

Commit 641cfee

Browse files
committed
Docs.
1 parent bd3fb3a commit 641cfee

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/Authenticator/PrimaryKeySessionAuthenticator.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Authentication\Authenticator;
55

66
use ArrayAccess;
7+
use Authentication\Identifier\IdentifierInterface;
78
use Cake\Http\Exception\UnauthorizedException;
89
use Psr\Http\Message\ResponseInterface;
910
use Psr\Http\Message\ServerRequestInterface;
@@ -13,6 +14,18 @@
1314
*/
1415
class 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
}

0 commit comments

Comments
 (0)