From 7204b01949a22008ec5b8f5c1a7a62e5427e5314 Mon Sep 17 00:00:00 2001 From: Mat Date: Wed, 23 May 2018 18:48:03 +0200 Subject: [PATCH] =?UTF-8?q?comment=20h=C3=A9riter=20de=20FOSUserBundle=20d?= =?UTF-8?q?ans=20le=20contexte=20de=20MonBundle=20(Techno)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit prendre le code du layout dans le vendor, et l'utiliser dans le contexte de mon bundle. voir https://openclassrooms.com/courses/developpez-votre-site-web-avec-le-framework-symfony/securite-et-gestion-des-utilisateurs-1#/id/r-3624754 php bin/console debug:router -> fos_user_security_login GET|POST ANY ANY /login fos_user_security_check POST ANY ANY /login_check fos_user_security_logout GET|POST ANY ANY /logout --- app/config/security.yml | 6 +++++- .../Resources/views/Default/login.html.twig | 15 +++++++++++++ .../Resources/views/layout.html.twig | 21 +++++++++++++++++++ src/TechnoBundle/TechnoBundle.php | 4 ++++ web/css/style.css | 7 ++++++- 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/TechnoBundle/Resources/views/Default/login.html.twig diff --git a/app/config/security.yml b/app/config/security.yml index be564c3..7202229 100755 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -16,7 +16,11 @@ security: form_login: provider: fos_userbundle csrf_token_generator: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4 - logout: true + login_path: fos_user_security_login + check_path: fos_user_security_check + logout: + path: fos_user_security_logout + target: fos_user_security_login anonymous: true access_control: diff --git a/src/TechnoBundle/Resources/views/Default/login.html.twig b/src/TechnoBundle/Resources/views/Default/login.html.twig new file mode 100644 index 0000000..75366bc --- /dev/null +++ b/src/TechnoBundle/Resources/views/Default/login.html.twig @@ -0,0 +1,15 @@ +
+ {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %} + {{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} | + + {{ 'layout.logout'|trans({}, 'FOSUserBundle') }} + + {% else %} + + {{ 'layout.login'|trans({}, 'FOSUserBundle') }} + | + + {{ 'layout.register'|trans({}, 'FOSUserBundle') }} + + {% endif %} +
diff --git a/src/TechnoBundle/Resources/views/layout.html.twig b/src/TechnoBundle/Resources/views/layout.html.twig index aedaf13..d4887aa 100755 --- a/src/TechnoBundle/Resources/views/layout.html.twig +++ b/src/TechnoBundle/Resources/views/layout.html.twig @@ -13,6 +13,9 @@
{% block header %} + + {% include '@Techno/Default/login.html.twig' %} +

cassis

la dernière chance du moment

@@ -102,6 +105,24 @@

{{ block('title') }}

+ + {% if app.request.hasPreviousSession %} + {% for type, messages in app.session.flashbag.all() %} + {% for message in messages %} +
+ {{ message }} +
+ {% endfor %} + {% endfor %} + {% endif %} + +
+ {% block fos_user_content %} + {% endblock fos_user_content %} +
+ + + {% endblock %} diff --git a/src/TechnoBundle/TechnoBundle.php b/src/TechnoBundle/TechnoBundle.php index e9f06a0..03ac54a 100755 --- a/src/TechnoBundle/TechnoBundle.php +++ b/src/TechnoBundle/TechnoBundle.php @@ -6,4 +6,8 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; class TechnoBundle extends Bundle { + public function getParent() + { + return 'FOSUserBundle'; + } } diff --git a/web/css/style.css b/web/css/style.css index 0ecf6bb..0f1f571 100755 --- a/web/css/style.css +++ b/web/css/style.css @@ -104,7 +104,12 @@ div.container { #header .container { padding-bottom: 1px; min-height: 120px; - + position: relative; +} +#header .container #login { + position: absolute; + top: 1em; + right: 3em; } #hero .container { padding: 0; -- GitLab