Sonata Admin + FOS User Bundle - add captcha to login form - symfony

I'm looking for a way to add captcha to Sonata User Bundle login form (and the validation of captcha of course!).
I couldn't find literally anything about using captcha in Sonata User Bundle, so I hope someone already been doing that and could perhaps help a bit?
#EDIT
Following Frankbeen's answer I've already extended AdminSecurityController (from sonata user bundle) which does have loginAction (for showing login form) and the form itself.
Unfortunately the captcha is not checked (loginAction is not called once we submit the form). That makes me wonder what's the controller:action used to actually check the submitted form? Maybe it's done via some sort of event listener?

Start reading from the a) Define New Template In app/Resources paragraph and overwrite the Security/login.html.twig template.
Follow this page, overwrite the SecurityController and add your logic for the Captcha.
Personally i like the Google Recaptcha. If you want to use that one you could also use the EWZRecaptchaBundle.

I believe I found the solution. To achieve what I wanted I just had to override UsernamePasswordAuthenticationListener following this answer:
Adding Captcha to Symfony2 Login Page

Related

symfony2 fosUserBundle add field with data from entity

I want to add a "select" field on the login form with data from an entity.
My question is can I do it with fosUserBundle or do I have to remove fosUserBundle because I really need both but I don't see I to do it.
Override the registration is quite simple but I think it's more complex with the login form.
Thanks for your reply
This is all documented. I guess you're gonna need to override the login template, you can learn how to do that here :
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_templates.md
You'll probably want to implement some custom login logic as well, which can be done by overriding default controller, this is documented here :
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_controllers.md

Symfony2 FOSUserBundle Error Summary

I'm using the Symfony2 FOSUserBundle and on the registration page, it puts inline errors beside the form elements that are in error, but I'd like to also display those errors in a summary at the top of the screen. Is there an error collection returned to the view that I'm not finding? Or is there another way to accomplish this?
Thanks!
If you check the default layout in user login page github link you'll find a variable called error.
Which was set in the login controller here
So I'm assuming you could move this error variable to where ever you want in your template.
Hope this is what you were asking for.
Overwrite the registration template (these are two files ) in your userbundle and then take a look here
http://symfony.com/doc/current/cookbook/form/form_customization.html
To see how to show every single one of your error-messages in your template.
This is the quickest way. You can also customize form appearance globally.

Extend SonataProject? Form fields or different forms for custom ROLES. Symfony 2 + FOSUserBundle + SonataUserBundle

I have a problem. I have already installed
into my Symfony 2 FOS User Bundle and Sonata User Bundle with all dependencies.
Configuration have done and I can manage my users and roles.
But, I am going to create other form to add / edit users in my panel
for diferent ROLE. How can I do that?
Create multiple forms for each role and check it in Sonata\AdminBundle\Controller\CRUDController?
Remove / add fields in form when is it creating?
Any ideas?
You could also have done something like
extend the normal crud controller,
change into your service the name of the controller you want to use (not sonata_crud but the controller you created in the step before)
in that new controller create an action for the newSpecialRoleAction and createSpecialRoleAction with your code with their corresponding views
...from what i remember
I solved it this way..
In base_edit.html.twig from Sonata Bundle I have
if statement, which check for me, that user has appropriate role
to show concrete fields in form.
It's "hard coding", but I didn't invent anything else.
Any other ideas?

Embed registration page on another page in Drupal?

Currently you can get to the registration page by going here: user/register
I need to be able to embed the registration form on ANOTHER page. How do I do that?
You could try the method suggested here: http://drupal.org/node/248275
a.k.a. embed the form using the PHP Code input filter:
<?php
print drupal_get_form('user_register');
?>
However, there will be a few gotchas with trying to embed the user registration page anywhere besides /user/register, because of the way Drupal's User module is set up.
It might be better for you to form_alter the user registration form, so you can customize it to fit your needs. Or, you might be able to get by with adding a block specifically to the user registration page.
What exactly are you trying to achieve by adding the registration page somewhere else?

custom page in Drupal

hi i have created a website in drupal.In this registration page can be access by following url
http://mysite.com?q=user/register
But i want to make a custom page for registration.
Please give me some guide line , i don't have any idea for this
You want to modify the user registration form,
http://www.google.ca/search?client=safari&rls=en&q=user+registration+template+drupal&ie=UTF-8&oe=UTF-8&redir_esc=&ei=Jn0dTdTzI466sQP4uZ2PCg
a) hook_form_user_register_alter() documentation at http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_form_alter/6 b) if you totally cant do what you want with a happy little form altering then you can always hook_menu_alter() the page and use whatever page callback you desire instead of drupal_get_form.
Goto admin/build/modules
Enable Profile module
Add fields in profile and while adding a field make it 'visible during registration'

Resources