-
Notifications
You must be signed in to change notification settings - Fork 26
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
Accessing the currently logged in user object #8
Comments
I came with a way to get the user object. I created a service for getting the user based on the username returned from the token getUser() see method getUser() However, it all fal s down. My users immediately lose access to their tokens on the next request after invoking an api call that updates their username. see setUsernameAction: https://github.com/jayrulez/sfapp/blob/31a5865d378dd2565fffbd486bff4b586ede47a2/src/AppBundle/Controller/UserController.php This is because the relationships in authbucket are username based instead of id based. Typically users may change usernames but never their ids. I think it would be better to make authbucket relationships id based. |
I added this workaround to my project: However, I do not think this is a very clean solution |
How can I get access to the currently logged in user object?
A call to $this->getUser(); in an action returns null.
$this->get('security.token_storage')->getToken()->getUser(); only returns the user name.
The code is here: https://github.com/jayrulez/sfapp/blob/9a767712acc747ff34d9a6d6ca35484ebf28af60/src/AppBundle/Controller/UserController.php
The text was updated successfully, but these errors were encountered: