EasyAdminBundle + FOSUserBundle user management - symfony

I am doing a back office under symfony and easy admin bundle and FOSUserBundle. I would like to know if it was possible when the admin connects in his space, he sees only the normal users, which do not have the role admin only.
or separate administrators from normal users.
I ask the question because using Sonata I know it's possible, but since I have to do it under easyadmin I do not know if it's feasible.
I have been trying to do this for a while now and I would like to know if it was possible.
Merci d'avance :)

In easy admin bundle you can filter entities with a DQL FILTER see the documentation here
You can use this for dislplaying only normal users.
you can try this filter:
dql_filter: "entity.roles NOT LIKE '%%env(ROLE_ADMIN)%%'"
as you seem to be French-speaking, here is a very interesting article about easyadminbundle

Related

Wordpress Parent/Child user registration

I am trying to evaluate the possibility of creating a plugin for Parent/Child functionality in Wordpress user creation.
What we need to achieve is to allow a Parent to create a sub-user account for his children. This accounts will have limited access but that can be done later with other Wordpress plugins.
What does not exist right now or what I was unable to find, is a plugin which gives the possibility to an existent standard user, to create sub-accounts related to him.
I do not want anything particular except the association between the accounts. The main user should have the possibility of adding or removing his child accounts.
Do you think this is something that is ok to do? Does it open us to any hacking possibility or vulnerability or create problems in the future?
If not, what would be in your opinion the best way to proceed and do this? What would be the best, fastest and most secure flow of operations?
Looking forward to your opinions.
Thanks in advance.
Regards
I know this is an old post but here's an option for anyone searching for this in the future.
First, you need to register a new user role. When you register the role, you are free to assign any capability you want. In this case, give the new role the capability to add users.
Then you can create a one-to-many relationship between the new user role and the standard subscriber role. So the new user role can have many subscribers but a subscriber can only belong to one new user role.
This will do what you want. There are several plugins that can do this if you are not comfortable with coding which seems the case per the OP's question. You can try PODS which is free and available in the Wordpress Plugin Directory - https://wordpress.org/plugins/pods/.

sonataadmin as both frontend and backend for symfony 2 project

I used sonataadmin and really like some features, like creating an entity and its related entity in the same page. I want to use it for frontend user also. Is it possable to use sonamaadmin for both backend and frontend users? Or is there another bundle allowing me to create an entity and its related entity in the same page?
Those are just form types, provided by the SonataAdminBundle. You can use them in any form.
You probably looking for the sonata_type_model or sonata_type_collection. See the documentation for more information.
Of course you can use Sonata Admin in both, although will be like only having a backend and made the correct security configuration for two kind of users. About entity and its related entities in the same page, that has nothing to do with Sonata, this can be achieved with symfony simple and embed forms.

Sonata User Bundle + FOS User bundle + Custom user bundle

i'm little confused..
I'm using sonata admin bundle in my project and i'd like to install user management for this, tell me please do i really have to install sonata user bundle? (i was using this tutorial http://domitable.com/content/getting-started-symfony-23-sonata-admin-user-bundles ) or only fos user bundle will be enought? i'm asking this becouse i want to install as little dependiendes as possible.
honestly the best way for me would be to use only my custom user bundle with custom user entity..(if need be only my class + FOS)
Do i have to use easy-extends to generate my user entity class or default doctrine generate entity is okay?
What about sonata ACL in this sitaution?
what is the best way to resolve this issue?
I'll try my best with what I have. Basically, SonataUserBundle is only useful if you want to manage the users via SonataAdmin.
FosUserBundle is simply a bundle that manages users and some actions such as login, but from the point of view of a user. That is, it does not have the tools built in for an admin to manage users.
Therefore, to manage the users, you need SonataAdmin and SonataUser.
If you easy extends SonataUser, then you could transfer your custom entity in the extended bundle. That is a way you could do it.
ACL is a complete different thing, read here for more information:http://symfony.com/fr/doc/current/cookbook/security/acl.html

Sonata Admin: Let users only edit entities they own (ACL)

I have Sonata Admin set up with ACLs. I have different users, groups and permissions which work fine. To achieve this, i followed the Sonata Admin documentation on ACLs.
So here is my question: What is a clean way to ensure that backend (admin) users can only view, edit and delete the entities they created with Symfony's and Sonata Admin's built-in ACL mechanisms? Sonata Admin automatically stores the owner (creator) of the object once it is persisted in the ACL tables (from the Sonata docs):
Owner:
when an object is created, the currently logged in user is set as owner for
that object and is granted all access for that object;
The same question has already been answered on Stackoverflow, but the answer does not explain in detail how to solve it with ACLs.
There is a new Symfony bundle doing just that: https://github.com/coopTilleuls/CoopTilleulsAclSonataAdminExtensionBundle
All you need to do is enable ACL in Sonata Admin, install the bundle and activate it. Pretty easy and effective, I use it in my Symfony2 project with Sonata Admin 2.2.
I saw 2 ways to do that:
Create a custom AclVoter
Override your Admin Class' CreateQuery()
I was not able to do any of these for doing the very simple thing that I needed, but I think this is the idea.
Actually this is one of many Symfony things on which I spent many hours and thousands lines of code without big success... Such simple needs should not be as much pain in the arse...
Don't grant the EDIT permission to the users. They can edit the instances they own but not others' instances.
I use this configuration:
#app/config/config.yml
sonata_admin:
security:
information:
STAFF: [VIEW, LIST, CREATE]
EDITOR: [OPERATOR, EXPORT]
ADMIN: [MASTER]
Documentation

Easiest way to integrate captcha's into Symfony2 FOSUserBundle registration?

I'm using Symfony2 and the FOSUserBundle to manage registration and logins. I'd like to add a captcha system. Is there are pre-existing bundle or tutorial on this?
Of course, I could try to roll my own using Google re-captcha. In that case, is Google reCaptcha a good choice, or should I use some other API?
There are indeed a bundles for that, take a look at:
CaptchaBundle
Or
EWZRecaptchaBundle
Both got (most likely) all the documentation you need added in the README.md file or extended documentation.
I just wrote a tiny bundle called caitcha-bundle.
According to this part of the fos user bundle documenation implementation should be quite easy because you only have to activate the caitcha bundle and add $builder->add('caitcha', 'caitcha'); to the form type.
Because captcha images and any other approaches that require some user interaction which is not related to the form itself are very annoying in my optinion, I tried to implement an invisible bot protection by using the honeypot method and a check for the time it took to fill in the form. It works well for my use cases but still has to be extended by more checks I suppose. I would appreciate any suggestions to improve this bundle.

Resources