-
Notifications
You must be signed in to change notification settings - Fork 95
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
Logging in wrong user type #76
Comments
Can you clarify this point? |
The $user passed to refreshUser() in UserProvider.php is the user I have attempted to log in with. Correct at this point. But when the findUserBy() function is called in PUGX\MultiUserBundle\Doctrine\UserManager.php, the incorrect user is returned:
The $classes variable holds each of my user entities. Correct at this point. But, as an example, the first class it loops over here is User A, querying user ID 2. The result is successful and User A with ID 2 is returned to the refreshUser() function. But actually, I was attempting to log in as a User B type. But because my User B that im attempting to log in as also has an ID of 2, the foreach loop does not get queried beacuse user ID 2 was found in the first class of the loop and returned before reaching the next class. Hope that makes more sense? Thanks |
Not sure if this is a bug or something I have done wrong with my set ups.
Using PUGXMultiUserBundle with FOSUserBundle to create 3 different user types (admin, User A, User B). I started encountering errors where when I logged in as User A, I found myself logged in the admin area. When I logged in as User B, I found myself in User A area. Not good!
After hours of tracing what was going wrong I found it...
FOS\UserBundle\Security\UserProvider.php
What was going wrong is that where the user manager queries a user by ID - I had users across the 3 different database tables with the same ID, so although the correct user entity was being searched for, it was finding a user with the same ID in a different table before it got to the correct one.
Im not sure the best way to fix this but for now I have just had to changed the user query line to this (all my users will have a unique username):
Any ideas how we can fix this permanently?
Thanks
The text was updated successfully, but these errors were encountered: