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

Added identity field funcionality and its unit test. #43

Merged
merged 2 commits into from
Nov 13, 2014

Conversation

victuxbb
Copy link

Hi! I have seen that there is a param in yaml config to set "user_identity_field" but this method forces the field to be "username".
Personally I need a token with "email" and not "username", I have rewritten this method using ReflectionClass...

With this code, the "user_identity_field" is full configurable.
Thanks!

$reflectionClass = new \ReflectionClass($user);
$reflectionProperty = $reflectionClass->getProperty($this->userIdentityField);
$reflectionProperty->setAccessible(true);
$payload[$this->userIdentityField] = $reflectionProperty->getValue($user);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi :) maybe a PropertyAccess would be more convenient than a reflection, it could allow to pass a path in $this->userIdentityField.

$accessor = \Symfony\Component\PropertyAccess\PropertyAccess::createPropertyAccessor();
$payload[$this->userIdentityField] = $accessor->getValue($user, $this->userIdentityField);

@victuxbb
Copy link
Author

@cedric-g Thanks! it's a better solution, i didn't know PropertyAccesor :)
I already implemented your suggestion.

@slashfan
Copy link
Contributor

Nice addition 👍 Thanks !

slashfan added a commit that referenced this pull request Nov 13, 2014
Added identity field funcionality and its unit test.
@slashfan slashfan merged commit 32ab07d into lexik:master Nov 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants