I have a User
entity, which implements UserInterface, \Serializable, EquatableInterface
It is set in the security settings:
security:
encoders:
AppBundle\Entity\User:
algorithm: sha512
providers:
our_db_provider:
entity:
class: AppBundle:User
property: email
firewalls:
main:
anonymous: ~
provider: our_db_provider
form_login:
login_path: login
check_path: login
access_control:
- { path: ^/ , roles: IS_AUTHENTICATED_ANONYMOUSLY}
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/registration, roles: IS_AUTHENTICATED_ANONYMOUSLY }
#...
I would like to select a user from the database and log in the current visitor, as the selected user.
$user = $em->getRepository('App\Entity\User')->find($user_id);
I have no idea, how to manage it. I am not using FOSUserBundle
. I've searched for the solution, but I can't found anything, just the AuthenticationUtils
, which only works with form submits.