Symfony2 fos login, register and forget your password in one view

I need to apply the purchased template to our dashboard. In this template, the login , register and forgotten passwords are under the same view and switch between them using simple jQuery.

I was looking for a good, not too flashy way to combine all three forms into one, but I came up with an empty one.

My constant parameters (as I see them), and why I do not like them:

  • Take the views from the fos package, copy them to /app/Resources/FOSUserBundle/views/, delete the part {% extend %}and {% include %}in my own login window. The reason for the hostility: for me it is a bit like a quick n-dirty fix - "this part does not work? Let me break it!" :)
  • Extend the fos package, accept the additional parameter in LoginActionand RegisterActionuse {% render %}with the parameters in my own login window. The reason for the hostility: expanding the whole package and changing two different controllers just to change the way it is displayed, similar to a bad MVC.
  • XHR downloads everything. Dislike reason: This approach makes sense when using internal pages, but for pages that reload, it just doesn't make sense.

TL version of the DR: . I am looking for a way without hacking, including registration, registration and a forgotten password form on one page.

Any help would be greatly appreciated!

+4
source share
1 answer

I found a solution that is convenient for me to work with for my current project. Advantages and disadvantages of the proposed solution:

Benefits:

  • several LOCs to implement
  • FOSUserBundle update proof (does not override view scripts *)

Disadvantages:

  • performance overhead due to subqueries
  • , ( ) , FOSUserBundle
  • - - , .

* layout.html.twig


, :


  • , :

    <div>
        <h2>Login</h2>
        {{ render(controller('FOSUserBundle:Security:login', { embeddedForm: true})) }}
    </div>
    <div>
        <h2>Reset</h2>
        {{ render(controller('FOSUserBundle:Resetting:request', { embeddedForm: true})) }}
    </div>
    
  • FOSUserBundle
    , , FOSUserBundle, . FOSUserBundle , {{ render ... }}. , . :

    {# app/Resources/FOSUserBundle/views/layout.html.twig #}
    {% if app.request.get('embeddedForm') %}
        {% set layout = 'AcmeBundle::layout-content.html.twig' %}
    {% else %}
        {% set layout = 'AcmeBundle::layout.html.twig' %}
    {%  endif %}
    {% extends layout %}
    
    {% block content %}
        {% block fos_user_content %}{% endblock %}
    {% endblock %}
    
  • AcmeBundle::layout-content.html.twig file
    content FOSUserBundle :

    {# src/Acme/DemoBundle/Resources/views/layout-content.html.twig #}
    {% block content %}{% endblock %}
    

(CSRF ..). FOSUserBundle.


:

  • , FOSUserBundle.
+3

All Articles