Skip to content

Commit

Permalink
Fetch the Identity from AthnIdentity for controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Nov 29, 2023
1 parent a48e69d commit 076789c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ public function __construct(
*/
protected function getIdentity(): Identity
{
$user = $this->getUser();

$authenticatedIdentity = $this->getUser();
// During authentication, an AuthenticatedIdentity is created, a decorated Identity.
// The app wants to work with the 'regular' Identity DTO from Middleware (client bundle)
// So we extract the entity here
$user = $authenticatedIdentity->getIdentity();
if (!$user instanceof Identity) {
$actualType = get_debug_type($user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function __construct(private readonly Identity $originalIdentity)
{
}

public function getIdentity(): Identity
{
return $this->originalIdentity;
}

public function getUsername(): string
{
return $this->originalIdentity->id ?: '';
Expand Down

0 comments on commit 076789c

Please sign in to comment.