Skip to content

Use getAuthIdentifier() instead of getKey() to retrieve current user identifier #1006

@s207152

Description

@s207152

In core framework, getAuthIdentifier() is used to get user identifier for authentication.
However, in passport getKey() is used to get user identifier.

Below are the places where made us confused:

public function forUser(Request $request)
{
$tokens = $this->tokenRepository->forUser($request->user()->getKey());
return $tokens->load('client')->filter(function ($token) {
return ! $token->client->firstParty() && ! $token->revoked;
})->values();
}

protected function approveRequest($authRequest, $user)
{
$authRequest->setUser(new User($user->getKey()));
$authRequest->setAuthorizationApproved(true);
return $this->convertResponse(
$this->server->completeAuthorizationRequest($authRequest, new Psr7Response)
);
}

In our case, we used uuid as auth identifier but kept primary key as $primaryKey field for relationships.

Would you consider to change to use getAuthIdentifier() to be in sync with core framework design?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions