FOSUserBundle redirect from login page after logged in

The easier solution is to add these two lines to your app/config/security.yml: always_use_default_target_path & default_target_path, e.g.: firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider login_path: /login check_path: /login_check always_use_default_target_path: false default_target_path: /your/start/path/

Multiple entity manager for FOSUserBundle

As you can see, FOSUserBundle can have only one EntityManager. You can see it from the settings orm.xml <service id=”fos_user.entity_manager” factory-service=”doctrine” factory-method=”getManager” class=”Doctrine\ORM\EntityManager” public=”false”> <argument>%fos_user.model_manager_name%</argument> </service> Parameter %fos_user.model_manager_name% specified in settings as model_manager_name fos_user: db_driver: ~ # Required user_class: ~ # Required firewall_name: ~ # Required model_manager_name: ~ So into the constructor comes the instance … Read more

The service “fos_user.mailer” has a dependency on a non-existent service “templating”

In Symfony 3.4 and FosUserBundle 2.0, add a service mailer into the fos_user config: fos_user: db_driver: orm # other valid values are ‘mongodb’ and ‘couchdb’ firewall_name: main user_class: AppBundle\Entity\User service: # this lines mailer: fos_user.mailer.twig_swift # this lines from_email: address: “%mailer_user%” sender_name: “%mailer_user%

Symfony2 AJAX Login

David’s answer is good, but it’s lacking a little detail for newbs – so this is to fill in the blanks. In addition to creating the AuthenticationHandler you’ll need to set it up as a service using the service configuration in the bundle where you created the handler. The default bundle generation creates an xml … Read more

Symfony2 $user->setPassword() updates password as plain text [DataFixtures + FOSUserBundle]

Since you are using FOSUserBundle, you can use UserManager to do this. I would use this code (assuming you have $this->container set): public function load(ObjectManager $manager) { $userManager = $this->container->get(‘fos_user.user_manager’); $userAdmin = $userManager->createUser(); $userAdmin->setUsername(‘System’); $userAdmin->setEmail(‘system@example.com’); $userAdmin->setPlainPassword(‘test’); $userAdmin->setEnabled(true); $userManager->updateUser($userAdmin, true); }

Remove / Replace the username field with email using FOSUserBundle in Symfony2 / Symfony3

A complete overview of what needs to be done Here is a complete overview of what needs to be done. I have listed the different sources found here and there at the end of this post. 1. Override setter in Acme\UserBundle\Entity\User public function setEmail($email) { $email = is_null($email) ? ” : $email; parent::setEmail($email); $this->setUsername($email); return … Read more

tech