FAQ Database Discussion Community


Append inline scripts inside Twig layout block

php,symfony2,templates,twig,fosuserbundle
I have a layout that looks like this: <html> <body> <!-- Omitted --> <div class="content"> {% block body %}{% endblock %} </div> <script src="js/vendor.js"></script> {% block javascripts %} <!-- I want to be able to inject inline scripts from sub-templates here --> {% endblock %} </body> </html> Then I have...

FOSUserBundle + HWIOAuth security configuration failed

php,symfony2,fosuserbundle,hwioauthbundle,symfony-2.6
I'm trying to get FOSUserBundle and HWIOAuth working together for handle the authentication of two types of users: representatives and interns. The representatives ones would begin using HWIOAuth and would use Salesforce and internal FOSUserBundle. I'm trying to set everything but I have problems because Symfony throws this error when...

Can and Should I cache symfony2 getUser()

symfony2,doctrine,fosuserbundle
I am using Symfony ( current version 2.6.4 ) whenever I want to check if a user is loggedin ( I am also using FOSUserBundle ) I use $user = $this->getUser(); in my controller which works out just fine but if I open 10 links in 1 second this query...

FOS UserBundle invitation: how to send an invite?

symfony2,fosuserbundle
I installed the invitation extension to FOSUserBundle. Everything seems to be working fine but I can't understand how to send an invitation: do I have to implement it or it is already and I simply need to find the correct path (and what is it please?) thanks...

symfony2 Multidatabase login or change database by host

php,symfony2,fosuserbundle
It is possible in symfony2 and fosuserbundle (or inner) to make it: When I enter to site by host example.com I choose "example" database, then I can login to user in this database. When I enter to site by host exaple2.com I choose "exaple2" database where are other users and...

Rewrite URL in Symfony2 with FOSUserBundle

apache,symfony2,mod-rewrite,url-rewriting,fosuserbundle
I have a domain and a different server with a Symfony2 website. I created a proxy redirection from the domain name to the server. That's working now. But I have a problem. When I want to login with the FOSUserBundle, I see my IP address of the server (http://xxx.xxx.xxx.xxx/login). I...

Issue with loading thread participants using Symfony FosMessageBundle or OrnicarMessageBundle

symfony2,fosuserbundle
I want to provide messeging features in my project on symfony with FosMessageBundle. Following documentation I use this string of code to load all inbox threads. $provider = $this->container->get('fos_message.provider'); $threads = $provider->getInboxThreads(); The result of dump of each thread in twig is: Thread {#1300 ▼ #id: 7 #createdBy: User {#1129...

Symfony2: FOSUserBundle Delete Action Error

php,symfony2,fosuserbundle
Fairly new to Symfony2; I am now using FOSUserBundle as my userprovider. Since it doesn't provide a controller for delete actions, I wrote my own: /** * Delete user * * @param integer $id * * @Route("/delete/{id}") * * @return RedirectResponse */ public function deleteAction($id) { $em = $this->getDoctrine()->getManager(); $um...

symfony2 how to store session differently on one domain/IP with to different application

php,session,fosuserbundle,symfony-2.3
I have two different projects in symfony2. I am using symfony2.3 version. I have used fosuserbundle for user authentication. I have one server. I have uploaded my both projects at /var/www/html/project1 /var/www/html/project2 And i am accessing my two applications/projects like http://202.12.0.0/project1 and http://202.12.0.0//project2. (IP here is given only for example....

Save user's ID in database with Symfony 2.6

php,symfony2,fosuserbundle
still getting to grips with Symfony so please excuse me if this is already asked. I don't quite understand how to send data to forms to be processed properly so am need of a bit of guidance. My issue is i wish to save my logged in user's ID into...

Symfony2 FOSUserBundle two login form error configure the check path

php,symfony2,login,fosuserbundle
i need to have 2 login form. 1 -> main site 2 -> my backend i have see many thread for this. I try to do it, but i have an error : "You must configure the check path to be handled by the firewall using form_login in your security...

When accessing at the same time, it stops at a fire wall. : Security : Symfony2

php,symfony2,fosuserbundle
environment, precondition The authentication function (Security) is mounted. (config : firewalls) FOSUserBundle bundle is installed. The following processing is carried out in the login state. There is simple action. routing : demo_home_index indexAction() { sleep(60); return // ... } And, there is an action by which a file is...

Change role of one user no working with Symfony2

symfony2,fosuserbundle,roles
Sorry if this question has been asked many times but I didn't found any solution on the Web. So, I just have installed FOSUserBundle and I've created 2 users on my application with the console. The problem is they don't have any role. So in on controller, I get the...

FOSUserBundle reset password: weird behaviour

symfony2,user,bundle,fosuserbundle
I'm trying to make my own form for allowing user to edit his profile. I success to add my field at the FosUserBundle original fields but I have a weird behaviour. My user can change his password only one time !! If I retry to change it from the form...

Symfony2 FR3DLdapBundle and FOSUserBundle insert in database

symfony2,ldap,fosuserbundle,fr3dldapbundle
I joined the identifiaction LDAP fos. The identification works well but fosuser add my user in the database. I wish I disable the insert in the database. Also, if I try to reconnect, it tries to reintegrate the user. How to disable fos_user_security_check? Or deactivate the check of fosuser. Thanks...

Fosuserbundle register validation not work

php,symfony2,doctrine,fosuserbundle
When I register with an existing email, in the registerAction RegisterController $form->isValid() returns true despite that there is a constraint that exists in Fosuserbundle but I got an DBALException (An exception occurred while executing 'INSERT INTO … '). I created a bundle that inherits FOSUserBundle and MyUser entity inherits BaseUser...

More than one firewall at Symfony2 project security.yml, how to deal with pattern?

php,symfony2,fosuserbundle,hwioauthbundle,symfony-2.6
I am working in a project where I will need two firewalls or secured areas. The first firewall/secured area will allow login/logout using HWIOAuthBundle using Salesforce as provider, the second firewall/secured area will allow login/logout through FOSUserBundle since this is for internal sysadmin and so on. I have a doubt...

Symfony 2 : FOSUserBundle : Using FOSUserEvents for Redirection

php,symfony2,fosuserbundle
I have implemented FOSUserBundle in my Symfony 2 project to manage my members. Each time a form is successfully filled (registration, changing password...) I redirect the user to my homepage. To do this I use the SUCCESS events provided by the bundle (see the documentation : Hooking into the controllers)....

ClassNotFoundException Symfony UserBundle

symfony2,fosuserbundle
I'm developping a website on Symfony2, I want to intergrate FOSUserBundle. I am using Doctrine ORM User class. I've followed the installation steps but I got this error: ClassNotFoundException in AppKernel.php line 21: Attempted to load class "FOSUserBundle" from namespace "FOS\UserBundle". Did you forget a "use" statement for another namespace?...

Is there a way to use the FOSUserBundle without a mailer service

php,symfony2,fosuserbundle
I want to use FOSUserBundle but my application doesn't require a mailer service. Is there anyway I can configure it to not require one. Heres my config for fos: fos_user: db_driver: orm firewall_name: main user_class: acmeBundle/Custom/User/Class I've tried to configure it like so: fos_user: db_driver: orm firewall_name: main user_class: acmeBundle/Custom/User/Class...

SONATA USER BUNDLE/FOS USER BUNDLE

symfony2,fosuserbundle,sonata-admin,sonata-user-bundle
It's my first time with this Bundle. I have a little problem to display correctly the side to register someone. In fact, the layout is duplicate. I don't know why. I spent lot of time but I have not the answer at the moment. I join a picture to...

Error for array_merge() in symfony2

php,symfony2,fosuserbundle
I really got a big problem because when I login in app.php environment I got a warning .By the way I am using symfony2. Warning: array_merge(): Argument #1 is not an array in C:\xampp\htdocs\Editracker\vendor\friendsofsymfony\user-bundle\Model\User.php line 181 this is mu User.php public function serialize() { return serialize(array( $this->password, $this->salt, $this->usernameCanonical, $this->username,...

Symfony2 - app.user not synced with database

php,symfony2,session,fosuserbundle
I have a page called lobby in which a user can accept a friend request. Accepting a friend request leads to this action : public function acceptFriendRequestAction($requestId) { $user = $this->getUser(); // Here $user is modified and changes are saved in database return $this->redirect('ACAppBundle:Lobby:index'); } A template is rendered, using...

Symfony 2 - Adding user roles under the ROLE_USER

symfony2,fosuserbundle,roles
I'm trying to create a new role in Symfony 2 below the default USER_ROLE (that role would have limited write access to some features). I am using FOSUserBundle. I've written the following security settings so far but my ROLE_DEMO users still get the ROLE_USER. role_hierarchy: ROLE_DEMO: [] ROLE_USER: [ROLE_DEMO] ROLE_ADMIN:...

Symfony2 FosUserBundle is loosing session

php,symfony2,fosuserbundle
I am using FosUserBundle to register and authenticate users in my website. But i am having troubles with it cause user session is loosen very soon. Sometimes 5 minutes, sometimes 10 minutes, and then user is redirected to the login form again, causing many users to left my website. This...

Add class for password input in FOS Userbundle

symfony2,fosuserbundle
I want to override default registration form of FOS Userbundle and add a custom class to password input. So I've copied register.html.twig and register_content.html.twig into appropriate directory and edited register_content.html: {% trans_default_domain 'FOSUserBundle' %} <form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST" class="fos_user_registration_register"> {{ form_errors(form) }} {{ form_row(form.email, {'attr': {'class':...

Why do we need to check if user is instance of UserInterface

php,symfony2,fosuserbundle
I've noticed in FOSUserBundle Controllers (ProfileController) the check if the $user is instance of UserInteface $user = $this->getUser(); if (!is_object($user) || !$user instanceof UserInterface) { throw new AccessDeniedException('This user does not have access to this section.'); } Is it enough to check only if (!is_object($user))? If my user entity extends...

Logout doesn't redirect - Symfony2

php,security,symfony2,fosuserbundle,logout
Logout is successfuly performed and user is disconnected. The problem is that it doesn't redirect to the page set in configuration. It gives instead a 500 Internal Error with following error message: ContextErrorException: Warning: SessionHandler::write(): Parent session handler is not open in C:\xampp\htdocs\community\app\cache\dev\classes.php line 398 I am using Symfony2.3.25 and...

FOSBundle redirect loop

php,symfony2,fosuserbundle
I'm using SF2 together with FOS user bundle. security: providers: fos_userbundle: id: fos_user.user_provider.username encoders: FOS\UserBundle\Model\UserInterface: sha512 firewalls: dev: pattern: ^/(_(profiler|wdt|error)|css|images|js)/ security: false main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider logout: true anonymous: false access_control: - { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } -...

Delete FOSUserBundle error messages

symfony2,twig,fosuserbundle
i'm trying to remove from my form the generic FOSUserBundle message. That is the result when i've an error : i want to remove the message in the red square. And as you can see i succeeded to ad my own error message. I checked a ton of other forum...

Add roles field to FOSUserBundle group form [Solved]

symfony2,fosuserbundle
When activating group( base on its documentation) in FOSUserBundle, the group roles are not embedded on edit and update form!I already override GroupFormType and GroupController but I can't pass roles from controller to form class. my question is how can I add roles to form to let administrator change or...

fosuserBundle multiple firewalls check path configuration

symfony2,fosuserbundle
I am using Symfony2 2.3 and FosUserBundle. I am trying to create two firewalls. One for the administration section and the other for frontend. The front end firewall works fine but the admin one doesn't work and it displays this error You must configure the check path to be handled...

Undefined offset: 0. Doctrine and native sql

symfony2,doctrine2,fosuserbundle
I have little problem, I want to print id of user, but I have an error: "Undefined offest: 0". Here is my code: $rsm = new ResultSetMapping(); $em = $this->getDoctrine()->getManager(); $user= $this->get('security.context')->getToken()->getUser(); $query = $em->createNativeQuery('SELECT id FROM fos_user WHERE username_canonical = ?', $rsm); $query->setParameter(1, $user); $users = $query->getResult(); echo $users[0]['id'];...

Symfony2: Getting the “username” after an unsuccessful login attempt

symfony2,fosuserbundle,brute-force
I use Symfony2 and FOSUserBundle. I want to prevent brute force attacks on the login page. For this I created a listener on the event: AuthenticationEvents::AUTHENTICATION_FAILURE Besides the IP I'd like to get also the "username" that the user passed when trying to log. This way I can get the...

Symfony2 Redirect user after succesfull register with FosUserBundle

symfony2,fosuserbundle
I have tried a lot of method to resolv this problem, but it's still not working. What i want, is than after the user success to register he is redirecting to the wanted page. So, i have a UserBundle with : in UserBundle/EventListener namespace MDB\UserBundle\EventListener; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use...

Do we have to write the content of the fos_user_content when extending the layout?

forms,symfony2,fosuserbundle
Hello I'm trying to use a custom form for a user registration: In my layout.html.twig : {% extends 'ProjectBundle::project.html.twig' %} {% block content %} {% block fos_user_content %}{% endblock %} {% endblock %} It displays the form correctly. Now I want to customize the login page : I create a...

How to redirect after successful login setting default_target_path on all firewalls using FOSUserBundle and SonataAdminBundle in Symfony2 Security

symfony2,fosuserbundle,sonata-admin,symfony-security
This is my security firewall configuration: firewalls: # Disabling the security for the web debug toolbar, the profiler and Assetic. dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false # -> custom firewall for the admin area of the URL qis: pattern: /qis(.*) context: user form_login: provider: fos_userbundle login_path: /login check_path: /qis/login_check logout: path:...

FOSUserBundle When does SECURITY_IMPLICIT_LOGIN event gets fired?

symfony2,fosuserbundle
I've read here and you can see the following: /** * The SECURITY_IMPLICIT_LOGIN event occurs when the user is logged in programmatically. * * This event allows you to access the response which will be sent. * The event listener method receives a FOS\UserBundle\Event\UserEvent instance. */ const SECURITY_IMPLICIT_LOGIN = 'fos_user.security.implicit_login';...

Preventing users login from non authorized area

php,symfony2,fosuserbundle,symfony-security
To avoid me 403 errors when a user tries to access a forbidden area and avoid user sign in into that area I need to prevent users from logging if do not have the proper credentials. Let me explain a little better, suppose I'm the X user ROLE_USER, user X...

Install FOSUserBundle after cloning from Git

php,git,symfony2,fosuserbundle
I'm pretty new to Symfony2 so bare with me. I've created my own site on my local computer and it works wonderfully. I'm having tons of fun developing with it. But when it came time to move it to my server and test I ran into issue. I'm using the...

symfony2 FOSUserBundle data from the custom field do not write to the database

php,symfony2,fosuserbundle
I I read the documentation about overwrite a lot of times and I still don't know why this code doesn't work. Custom field - package works but data doesn't save in database. Company\UserBundle\Form\Type\RegistrationFormType.php namespace Company\UserBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Doctrine\ORM\EntityRepository; class RegistrationFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder,...

FOSUserBundle sending more email on user creation

email,symfony2,fosuserbundle
I'm developing a web site using Symfony2 and I'm using FosUserBundle to manage the users. On user registration I'd like to send a mail to admins to inform of the event. I followed the official FOS manual but I'm not able to override correctly the mail sending and anyway I...

Symfony 2.3 and FOSUserBundle with AJAX keeps throwing CSRF-Errors

php,jquery,ajax,symfony2,fosuserbundle
I am using Symfony 2.3 with FOSUserBundle and want to make a login form with AJAX. I found a view questions on SO (like this one) and even some other helpful sites (Adding an AJAX Login Form to a Symfony Project) that explained, how to use FOSUserBundle with ajax. Everything...

Access to /admin, why any user logged into the system can access?

php,security,symfony2,fosuserbundle,symfony-security
I have days trying to make this work and I can't so as a last resort I hope any can help me here. The point is that my application, as every application has a frontend which should be accessed by any user registered in the system except those that have,...

Sonata + FOSUserBundle edit roles on edit form

symfony2,fosuserbundle,sonata-admin
I am using SonataAdminBundle for user administration. I would like to change roles on users. Currently my code in configureFormFields method is like this but roles are never updated and I don't know why. // Fields to be shown on create/edit forms protected function configureFormFields(FormMapper $formMapper) { $formMapper ->with('General') ->add('roles',...

FOSUserBundle, Relation between User (roles) and Group (roles)?

php,symfony2,fosuserbundle
I am getting a bit confused with the roles in FOSUserBundle. The User entity also has roles column by which we can assign multiple roles to the user. According to the answer posted at Managing users/roles/groups in FOSUserBundle, we do not need separate entity or tables to manage user roles....

How to restrict access of action/method (of Controller) to specific user in Symfony?

php,symfony2,acl,fosuserbundle
Is there a way to restrict access to specific routes aka action/method of controller in Symfony based on user? I am implementing FOSUserBundle for user management and it has roles for defining permission that works well if I have user with defined roles but if I want to restrict the...

Error while generating doctrine entities with FOSUser Bundle in Symfony2

symfony2,doctrine2,fosuserbundle
I'm using FOSUser bundle and everything went ok until I tried to create the database entities, I get this error: It has nothing to do with the bug in Symfony 2.5, I'm using version 2.7 Case mismatch between loaded and declared class names: App\UserBundle\Entity\user vs App\UserBundle\Entity\User This is my config...

How to use the registration procedure of FOSUserBundle from a third controller

symfony2,fosuserbundle
I have to persist an entity (let's call it Entity for simplicity) in the database that has to be referenced to a User handled with FOSUserBundle. To make this reference I have a column entity_table.userId. When the new Entity is created, I have to: Create the User through the registration...

What is the issue with not overriding templates in symfony2.6 and FOSUserBundle 1.3

symfony2,templates,override,fosuserbundle
I'm trying to override the base layout of FOSUserBundle using the 'simple' option of making a cloned path as .app/Resources/FOSUserBundle/views/layout.html.twig , but symfony2.6 continues to render the template from inside the vendor directory. My composer requires: "require": { "php": ">=5.3.3", "symfony/symfony": "2.6.*", "doctrine/orm": "~2.2,>=2.2.3,<2.5", "doctrine/dbal": "<2.5", "doctrine/doctrine-bundle": "~1.2", "twig/extensions": "~1.0",...

Symfony - OAuth and basic auth together

symfony2,oauth-2.0,fosuserbundle,hwioauthbundle
So, I have this security: providers: fos_userbundle: id: hwi_oauth.user.provider.fosub_bridge firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: pattern: ^/ anonymous: true logout: true form_login: provider: fos_userbundle csrf_provider: form.csrf_provider login_path: /login check_path: /login_check oauth: resource_owners: battlenet: "/login/check-battle-net" login_path: /login use_forward: false failure_path: /login oauth_user_provider: service: hwi_oauth.user.provider.fosub_bridge logout: path: /logout...