From d08bce02091fc3488c2a990b66e98149ccf6e562 Mon Sep 17 00:00:00 2001
From: Serghei Mihai <smihai@entrouvert.com>
Date: Mon, 30 May 2022 14:17:13 +0200
Subject: [PATCH] misc: render authenticators names in their own templates
 (#53264)

---
 src/authentic2/apps/authenticators/models.py                | 1 +
 .../authentic2/login_password_registration_form.html        | 6 ++++++
 .../templates/registration/registration_form.html           | 3 ---
 src/authentic2_auth_fc/authenticators.py                    | 4 +++-
 .../templates/authentic2_auth_fc/login.html                 | 3 +++
 .../templates/authentic2_auth_fc/registration.html          | 5 +++++
 6 files changed, 18 insertions(+), 4 deletions(-)
 create mode 100644 src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html

diff --git a/src/authentic2/apps/authenticators/models.py b/src/authentic2/apps/authenticators/models.py
index 67e9d342a..98806970f 100644
--- a/src/authentic2/apps/authenticators/models.py
+++ b/src/authentic2/apps/authenticators/models.py
@@ -143,4 +143,5 @@ class LoginPasswordAuthenticator(BaseAuthenticator):
 
     def registration(self, request, *args, **kwargs):
         context = kwargs.get('context', {})
+        context['name'] = str(self)
         return render(request, 'authentic2/login_password_registration_form.html', context)
diff --git a/src/authentic2/templates/authentic2/login_password_registration_form.html b/src/authentic2/templates/authentic2/login_password_registration_form.html
index 003b87d11..335a9a01d 100644
--- a/src/authentic2/templates/authentic2/login_password_registration_form.html
+++ b/src/authentic2/templates/authentic2/login_password_registration_form.html
@@ -1,6 +1,11 @@
 {% load i18n gadjo %}
 
+{% block title %}
+<h2>{{ name }}</h2>
+{% endblock %}
+
 {% block registration %}
+<p>
 <form enctype="multipart/form-data" method="post" class="pk-mark-optional-fields">
   {% csrf_token %}
   {{ form|with_template }}
@@ -8,4 +13,5 @@
   <button class="submit-button">{% trans 'Submit' %}</button>
   </div>
 </form>
+</p>
 {% endblock %}
diff --git a/src/authentic2/templates/registration/registration_form.html b/src/authentic2/templates/registration/registration_form.html
index 29b0151a6..31e61ea8c 100644
--- a/src/authentic2/templates/registration/registration_form.html
+++ b/src/authentic2/templates/registration/registration_form.html
@@ -13,10 +13,7 @@
 
 {% for id, block in frontends.items %}
   <div class="registration_frontend">
-    <h2>{{ block.name }}</h2>
-    <p>
       {{ block.content|safe }}
-    </p>
   </div>
 {% endfor %}
 
diff --git a/src/authentic2_auth_fc/authenticators.py b/src/authentic2_auth_fc/authenticators.py
index 927e34f0c..9b34cb5da 100644
--- a/src/authentic2_auth_fc/authenticators.py
+++ b/src/authentic2_auth_fc/authenticators.py
@@ -57,7 +57,8 @@ class FcAuthenticator(BaseAuthenticator):
         )
         context['login_url'] = utils_misc.make_url('fc-login-or-link', keep_params=True, request=request)
         context['block-extra-css-class'] = 'fc-login'
-        template = 'authentic2_auth_fc/login.html'
+        context['name'] = self.name
+        template = kwargs.get('template', 'authentic2_auth_fc/login.html')
         return TemplateResponse(request, template, context)
 
     def profile(self, request, *args, **kwargs):
@@ -83,4 +84,5 @@ class FcAuthenticator(BaseAuthenticator):
         return render_to_string('authentic2_auth_fc/linking.html', context, request=request)
 
     def registration(self, request, *args, **kwargs):
+        kwargs['template'] = 'authentic2_auth_fc/registration.html'
         return self.login(request, *args, **kwargs)
diff --git a/src/authentic2_auth_fc/templates/authentic2_auth_fc/login.html b/src/authentic2_auth_fc/templates/authentic2_auth_fc/login.html
index 711a9c39b..c6263202c 100644
--- a/src/authentic2_auth_fc/templates/authentic2_auth_fc/login.html
+++ b/src/authentic2_auth_fc/templates/authentic2_auth_fc/login.html
@@ -1,6 +1,9 @@
 {% load static %}
 {% load i18n %}
 
+{% block title %}
+{% endblock %}
+
 {% block login %}
 <link rel="stylesheet" type="text/css" href="{% static 'authentic2_auth_fc/css/fc.css' %}">
 <div id="fc-button-wrapper">
diff --git a/src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html b/src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html
new file mode 100644
index 000000000..1033bf879
--- /dev/null
+++ b/src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html
@@ -0,0 +1,5 @@
+{% extends "authentic2_auth_fc/login.html" %}
+
+{% block title %}
+<h2>{{ name }}</h2>
+{% endblock %}
-- 
2.36.1

