fosuserbundle

Symfony2 FOSUserBundle error - FileLoaderImportCircularReferenceException

ⅰ亾dé卋堺 提交于 2019-12-10 15:14:04
问题 I'm trying to install FOSUserBundle on a new symfony2 project. I've followed the steps to get it installed but I'm still having trouble with this error: FileLoaderImportCircularReferenceException in FileLoader.php line 97: Circular reference detected in "/Users/tom/Sites/symfony/todo/app/config/routing_dev.yml" ("/Users/tom/Sites/symfony/todo/app/config/routing_dev.yml" > "/Users/tom/Sites/symfony/todo/app/config/routing.yml" > "/Users/tom/Sites/symfony/todo/app/config/routing_dev.yml"). When

Symfony2 / FOSUserBundle - Redirect after login according to the role

半城伤御伤魂 提交于 2019-12-10 14:24:23
问题 I would like to customize the redirection after login according to the user's role. FYI : I use symfony 2.8 I create this class : <?php namespace Users\UsersBundle\Redirection; use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Security; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RedirectResponse; use

allow only one connection on the same login with FOSUserBundle

岁酱吖の 提交于 2019-12-10 11:48:33
问题 I'm creating a website thanks to Symfony2 with FOSUserBundle. I'm triyng to deny multiple connections on the same login (but from different computers for example). I've 2 solutions : Create an event listner on authentification but I didn't manage to make it. (even with the cookbook). override the login_check method but my FOSUserBundle doesn't work if I do it. Do you have any better options? Or any solutions? 回答1: Got it finaly. There is just one last update to make to solve it all. You need

Login EventListener not firing on production side

倖福魔咒の 提交于 2019-12-10 11:45:40
问题 I have an event listener that should fire when a user logs in in my Symfony setup. I have the following in my services.yml ... d_user.login_listener: class: D\UserBundle\EventListener\LoginListener arguments: [] tags: - { name: 'kernel.event_subscriber', event: 'security.interactive_login' } and in my login listener I simply have this: <?php namespace D\UserBundle\EventListener; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; use Symfony\Component\EventDispatcher

random error symfony:ContextErrorException: Warning: simplexml_load_file(): I/O warning : failed to load external entity

梦想的初衷 提交于 2019-12-10 10:45:44
问题 In my project with Symfony, I have this random error appear when I go to random page in my application: ContextErrorException: Warning: simplexml_load_file(): I/O warning : failed to load external entity "C:\wamp\www\Symfony\vendor\friendsofsymfony\user-bundle\Resources\config\doctrine\model/User.orm.xml" in C:\wamp\www\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\Driver\XmlDriver.php line 736 Refresh the page many times seems to disable this error until it appears again. I think,

Update roles in security.context without need to logging in again

情到浓时终转凉″ 提交于 2019-12-10 09:54:22
问题 I use FOSUserBundle in my project. I have a Controller AcmeArticleBundle:Edit which has a route prefix /editor . And in my security.yml I added an access control. access_control: - { path: ^/editor/, role: ROLE_EDITOR } Now I add ROLE_EDITOR to a user in a controller. But user cannot access AcmeArticleBundle:Edit and security context does not change until logging out and logging in again. 回答1: You can update the roles manually: // YourController.php $roles = $this->getToken()->getUser()-

Creating Custom Field with FOSUserBundle

て烟熏妆下的殇ゞ 提交于 2019-12-10 08:43:55
问题 I want to add an address and telephone number using FOSUserBundle. How can I add a Custom fields, with FOSuserBundle, to have a profile that contains address and telephone number.... 回答1: Create an own user bundle and in the MyCompanyUserBundle.php you set public function getParent(){ return 'FOSUserBundle'; } Then in your new UserBundle you create a User entity and let it extend from the base user of the FOS user bundle: use FOS\UserBundle\Model\User as BaseUser; use Doctrine\ORM\Mapping as

FOSRestBundle How to validate the registration?

心已入冬 提交于 2019-12-09 23:29:27
问题 I'm developing a RESTFul API in Symfony 2.3.* with FOSUserBundle and FOSRestBundle, and I'm having trouble understanding how to create a registration method. My controller look like this : class UserRestController extends FOSRestController { //Other Methods ... public function postUserAction() { $userManager = $this->get('fos_user.user_manager'); $user = $userManager->createUser(); $param = $paramFetcher->all(); $form = $this->createForm(new UserType(), $user); $form->bind($param); if ($form-

Symfony2 access user and doctrine in a service

回眸只為那壹抹淺笑 提交于 2019-12-09 16:11:33
问题 I'm running the equivalent of this code in lots and lots of controller actions, basically it grabs the user's username, and if that username is attached to a blog entity it will allow the user to see the blog entity(s): $em = $this->getDoctrine()->getManager(); $user = $this->get('security.context')->getToken()->getUser(); $entities = $em->getRepository('MySiteBundle:Blog')->findBy(array('user' => $user)); return $this->render('MySiteBundle:Blog:index.html.twig', array( 'entities' =>

The good way to persist a FOSUser entity in cascade

帅比萌擦擦* 提交于 2019-12-09 13:46:19
问题 I want to persist a User entity extends FOSUserBundle entity but an error occured : SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'username_canonical' cannot be null How can I overload the persist function of my User entity to give the informations it needs ? My User entity : class User extends BaseUser { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * * @ORM\OneToOne(targetEntity="MyApp