简体   繁体   中英

Make a custom login screen for the HWIOAuth Bundle using bootstrap

{% extends '::base.html.twig' %}

{% block content %}
    <div>
        {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
            {{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
            <a href="{{ path('fos_user_security_logout') }}">
                {{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
            </a>
        {% else %}
            <a href="{{ path('fos_user_security_login') }}">{{ 'layout.login'|trans({}, 'FOSUserBundle') }}</a>
        {% endif %}
    </div>

    {% for type, messages in app.session.flashBag.all %}
        {% for message in messages %}
            <div class="{{ type }}">
                {{ message|trans({}, 'FOSUserBundle') }}
            </div>
        {% endfor %}
    {% endfor %}

    <div>
        {% block fos_user_content %}
        {% endblock fos_user_content %}
    </div>

{% endblock %}

for now my screen has an appearance just to appear buttons to login with facebook or gmail, like an example of how to do a more visual screen with the icons login and centralized.

Thank you.

            <div class="customBtn"><a href="{{ path('hwi_oauth_service_redirect', {'service': 'facebook'}) }}">
                    {% image 'bundles/delivveweb/images/Facebook.png' %}
                    <img src="{{ asset_url }}">
                    {% endimage %}
                </a></div>
            <div class="customBtn"><a href="{{ path('hwi_oauth_service_redirect', {'service': 'google'}) }}">
                    {% image 'bundles/delivveweb/images/Google.png' %}
                    <img src="{{ asset_url }}">
                    {% endimage %}
                </a></div>
            <div class="customBtn"><a href="{{ path('hwi_oauth_service_redirect', {'service': 'linkedin'}) }}">
                    {% image 'bundles/delivveweb/images/in.png' %}
                    <img src="{{ asset_url }}">
                    {% endimage %}
                </a></div>

I could do it this way to be a more customizable login menu also did a Provider and a controller to make the treatment of my User if someone needs to send a comment below to edit the answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM