简体   繁体   中英

FOS UserBundle User Manager - login after updateUser

I would like to ask whether the package Fos UserBundle when you add a user, you can log it with the user manager? If so, in what way?

$userManager = $this->container->get('fos_user.user_manager');
$user = $userManager->createUser();
$user -> setUsername('test');
$user -> setEmail('test');
$user -> setPlainPassword('test');
$user ->setEnabled(true);
$userManager->updateUser($user, true);`

`

Problem solved.

$loginManager = $this->container->get('fos_user.security.login_manager');
$firewallName =  $this->container->getParameter('fos_user.firewall_name');
$loginManager->loginUser($firewallName, $user);

Thanks for help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM