fosuserbundle

Disable CSRF token on login form

本秂侑毒 提交于 2019-11-30 06:41:59
I am using Symfony2.0 and FOSUserBundle, and would like to disable the csrf token on my login form. I have disabled the csrf protection globally on my website in my config.yml: framework: csrf_protection: enabled: false This is working well, there is no csrf field added to my forms. However, this does not apply to the login form. On this form only, I get an "Invalid CSRF Token" error if I don't include the token in the form with: <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" /> How can I disable the CSRF token on the login form? If you just go to your security.yml file and

FOSUserBundle login with email (Symfony2)

天大地大妈咪最大 提交于 2019-11-30 03:38:57
I have a question about the FOSUserBundle for Symfony 2.0.x. In there documentation you can find a way to change the login to work with either username and email. That works great! But I want to login to work with just the email. So I added a function in my CustomUserManager (extends from the original) that makes sure you just can logon with your email. namespace Frontend\UserBundle\Model; use FOS\UserBundle\Entity\UserManager; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; class CustomUserManager extends UserManager { public function loadUserByUsername($email) { /*

FOSUserBundle logout with prefix doesn't work

心已入冬 提交于 2019-11-30 03:33:34
问题 I am having a very strange problem with symfony2 and the FOSUserBundle. I can logout with /en/logout, but not with /nl/logout or /fr/logout. When I try to logout with nl or fr I get: You must activate the logout in your security firewall configuration. Although I configured it. I can't seem to wrap my head why the /en/logout works and the rest doesn't. This is my code: security.yml security: providers: fos_userbundle: id: fos_user.user_provider.username_email encoders: FOS\UserBundle\Model

Managing users/roles/groups in FOSUserBundle

大憨熊 提交于 2019-11-30 02:52:29
I am developing a simple CRUD to manage users/roles/groups of the application in which I am working. To manage users I'm using FOSUserBundle . What I want to do can be accomplished in several ways: Assigning roles to groups and then assign users to these groups Assigning roles to users directly But I have no idea how. I knew that FOSUser BaseUser class already has a column roles and in the documentation of FOSUser explains how to establish a ManyToMany relationship between users and groups but do not talk anything about roles. The only idea that comes to mind is to create an entity to manage

Symfony2 - Tests with FOSUserBundle

僤鯓⒐⒋嵵緔 提交于 2019-11-30 02:41:55
i would write a test for Symfony2 with FOSUserBundle. At the moment i tried some ways and no one works. I need a function like "createAuthClient". Here is my basic class. I post it because you could understand my problem better. <?php use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\BrowserKit\Cookie; class WebTestMain extends WebTestCase { protected static $container; static protected function createClient(array $options = array(), array $server = array()) { $client = parent::createClient

Create a symfony2 remember me cookie manually (FOSUserBundle)

不想你离开。 提交于 2019-11-30 00:54:24
Could somebody explain how you can manually create a remember me cookie in a controller? I want the users to stay logged in after they pressed the "register" button, without having to login with their credentials afterwards. I've tried to create a cookie manually but i'm guessing the cookie value is incorrect, and therefor the "remember me" functionality doesn't work. A cookie with the correct name gets set. I've checked that. The remember me functionality works as expected when using the normal login procedure with the user's credentials. security.yml security.yml remember me security:

how to add user roles dynamically upon login with symfony2 (and fosUserBundle)?

断了今生、忘了曾经 提交于 2019-11-29 23:08:20
问题 In my app users can switch between free user and premium user over time, when their subscription expires, they no longer have premium previleges. I thought I could cut a corner and not store the premium user role in the database, only store the date to which they have paid, thus eliminating the need for a cron job adding och removing the role premium from my users. The solution I had in mind was to do this on the user entity: public function __construct() { if ( $this->hasPlus() ) { $this-

how to secure whole pages except login page in symfony2?

☆樱花仙子☆ 提交于 2019-11-29 22:17:40
问题 I want to have whole site secured through login with FOSUserBundle. I tried to set security.yml like this security: encoders: Symfony\Component\Security\Core\User\User: plaintext FOS\UserBundle\Model\UserInterface: sha512 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: fos_userbundle: id: fos_user.user_manager firewalls: main: pattern: ^/ form_login: check_path: /login_check login_path: /login provider: fos_userbundle always

Custom FOSUserBundle Login Template using Bootstrap

自闭症网瘾萝莉.ら 提交于 2019-11-29 22:14:42
问题 I've installed Symfony2, FOS User Bundle and Twitter Bootstrap. Then I setup the /app/Resources/FOSUserBundle/views/layout.html.twig template to override FOSUserBundle to use my site template. It all works if I have a link to /login on the homepage. Now I want to implement a template like the hero template where the login form is part of the main template. The closest I've got is to use this in the main template: {% render controller("FOSUserBundle:Security:login") %} I can override the

Sonata User - Security on custom field

前提是你 提交于 2019-11-29 21:17:48
问题 I used SonataUser with FOSUser to manage my users and created a custom field company to attach each one to a given company. Now I'd simply need to give users the ability to manage only users attached to the same company: user1 company1 user2 company1 user3 company2 user4 company2 Example: user1 should be able to list/edit only user1 & user2 Should I use ACLs ? Can you point me to the right direction or tutorial to customize SonataUser for this purpose ? 回答1: Yes ACL is the way to go. create a