fosuserbundle

Symfony 4 fosuserbundle

只谈情不闲聊 提交于 2019-12-18 13:01:15
问题 I begin with Symfony 4 and I want to install FosUserBundle with this link : https://symfony.com/doc/master/bundles/FOSUserBundle/index.html First : My problem is that I don't know where to find the "app/config/config.yml" file to uncomment the translator and to configure : fos_user: db_driver: orm # other valid values are 'mongodb' and 'couchdb' firewall_name: main user_class: AppBundle\Entity\User from_email: address: "%mailer_user%" sender_name: "%mailer_user%" Second : I think that I have

Symfony2 App with RESTful authentication, using FOSRestBundle and FOSUserBundle

佐手、 提交于 2019-12-18 12:38:24
问题 I'm making REST API for my JS driven app. During login, the login form is submitted via AJAX to url /rest/login of my API. If the login is succesful, it returns 204 If it fails, it returns 401 While I have separated firewalls for the API and the app itself, they share the same context which should mean, that when user authenticates against the API, he's authenticated against the app too. So, when the server returns 204, page will reload and it should redirect user to the app, because he's now

Managing users/roles/groups in FOSUserBundle

独自空忆成欢 提交于 2019-12-18 11:17:39
问题 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

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

烈酒焚心 提交于 2019-12-18 11:16:06
问题 So, the above error has suddenly started happening, after I've been using FOSUserBundle for several Symfony projects. I've tried including the templating service (twice now) and it seems like it's installed fine. Here is my list of requires in my composer.json: "require": { "php": ">=5.5.9", "doctrine/doctrine-bundle": "^1.6", "doctrine/orm": "^2.5", "friendsofsymfony/user-bundle": "^2.0", "incenteev/composer-parameter-handler": "^2.0", "sensio/distribution-bundle": "^5.0.19", "sensio

FOSUserBundle - PHPUnit - Mock a user

孤街醉人 提交于 2019-12-18 08:55:37
问题 I am using Symfony with the FOSUserBundle and now I like to test some things like: Doctrine lifecycle Controller behind firewall For those tests I need to be a specific user or at least in a user group. How do I mock a user session so that ... The lifecycle field like "createdAt" will use the logged in user The Controller act like some mocked user is logged in Example: class FooTest extends ... { function setUp() { $user = $this->getMock('User', ['getId', 'getName']); $someWhereGlobal->user =

Change the role of a distant user without having to relog

你。 提交于 2019-12-18 02:57:32
问题 I am trying to change the role of a user, using the FOSUserBundle. The problem is: if the user is logged at the same time, he has to relog to see the new role. Any solutions ? 回答1: According to the Security Configuration Reference, there's a always_authenticate_before_granting option. There's not much informations about that, but I've tried it with custom roles loading from database and it does the trick. It looks like everytime you will make a new request, the security component will reload

How to restfully login, Symfony2 Security, FOSUserBundle, FOSRestBundle?

▼魔方 西西 提交于 2019-12-17 22:24:01
问题 I'd like to be able to login via a ws. I've tried to simulate this with curl pointing to /login but it only handles HTML, etc. By the way, it requires a CSRF which I don't want. So I'd like to either disable the CRSF (from the login_check ) or find a way to do it myself. Can I override the LoginListener (where is it?) which is used when the route login_check is catched. ANy clues? 回答1: There are many ways to provide authentication and authorization to a REST Web Service but the most accepted

Multiple entity manager for FOSUserBundle

梦想的初衷 提交于 2019-12-17 15:46:41
问题 To use different Entity Manager / Connection based on URL in Symfony if fairly easy. With the following routing configuration connection: pattern: /a/{connection} defaults: { _controller: AcmeTestBundle:User:index } and from the following Cookbook; How to work with Multiple Entity Managers and Connections My controller would look something like this; class UserController extends Controller { public function indexAction($connection) { $products = $this->get('doctrine') ->getRepository(

Symfony2 AJAX Login

女生的网名这么多〃 提交于 2019-12-17 05:34:08
问题 I have an example where I am trying to create an AJAX login using Symfony2 and FOSUserBundle. I am setting my own success_handler and failure_handler under form_login in my security.yml file. Here is the class: class AjaxAuthenticationListener implements AuthenticationSuccessHandlerInterface, AuthenticationFailureHandlerInterface { /** * This is called when an interactive authentication attempt succeeds. This * is called by authentication listeners inheriting from *

Symfony2 - Call to undefined method getDoctrine() when overriding FOSUserBundle's ProfileController

孤街浪徒 提交于 2019-12-13 18:24:08
问题 When I override FOSUserBundle's ProfileController and add these lines: $em = $this->getDoctrine()->getManager(); $resultat = $em->getRepository('PublishDemandsBundle:Demands')->findAll(); I get the following error: Call to undefined method Register\UserBundle\Controller\ProfileController::getDoctrine() in ProfileController.php. 回答1: Adding this alias-method to the controller fixed the issue: public function getDoctrine() { return $this->container->get('doctrine'); } 来源: https://stackoverflow