Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
s207152 opened this issue Apr 19, 2019 · 1 comment

Comments

@s207152
Copy link

s207152 commented Apr 19, 2019

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?

@driesvints
Copy link
Member

Hmm yes I believe so but we'd have to make the change on the next major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants