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..21abd6c8f
--- /dev/null
+++ b/src/authentic2_auth_fc/templates/authentic2_auth_fc/registration.html
@@ -0,0 +1,7 @@
+{% extends "authentic2_auth_fc/login.html" %}
+
+{% block title %}
+ {% block registration-block-title %}
+
FranceConnect
+ {% endblock %}
+{% endblock %}
diff --git a/src/authentic2_auth_fc/views.py b/src/authentic2_auth_fc/views.py
index cfc124c10..5c1bc476a 100644
--- a/src/authentic2_auth_fc/views.py
+++ b/src/authentic2_auth_fc/views.py
@@ -77,10 +77,15 @@ def login(request, *args, **kwargs):
)
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'
+ template = kwargs.get('template', 'authentic2_auth_fc/login.html')
return TemplateResponse(request, template, context)
+def registration(request, *args, **kwargs):
+ kwargs['template'] = 'authentic2_auth_fc/registration.html'
+ return login(request, *args, **kwargs)
+
+
def profile(request, *args, **kwargs):
# We prevent unlinking if the user has no usable password and can't change it
# because we assume that the password is the unique other mean of authentication
diff --git a/src/authentic2_auth_saml/templates/authentic2_auth_saml/login.html b/src/authentic2_auth_saml/templates/authentic2_auth_saml/login.html
index a170849ab..37ef41db1 100644
--- a/src/authentic2_auth_saml/templates/authentic2_auth_saml/login.html
+++ b/src/authentic2_auth_saml/templates/authentic2_auth_saml/login.html
@@ -1,5 +1,8 @@
{% load i18n %}
+{% block login-block-title %}
+{% endblock %}
+
{% block before-login %}
{% if authenticator.button_description %}
{{ authenticator.button_description }}
diff --git a/tests/conftest.py b/tests/conftest.py
index befe5f4be..8668e37bb 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -35,6 +35,7 @@ from authentic2.manager.utils import get_ou_count
from authentic2.models import Attribute, Service
from authentic2.utils import hooks as a2_hooks
from authentic2.utils.evaluate import BaseExpressionValidator
+from authentic2_auth_fc.models import FcAuthenticator
from authentic2_auth_oidc.utils import get_provider_by_issuer
from authentic2_idp_oidc.models import OIDCClient
@@ -556,3 +557,14 @@ def scoped_db(django_db_setup, django_db_blocker):
transaction.set_rollback(True)
return scoped_db
+
+
+@pytest.fixture
+def fc(db):
+ FcAuthenticator.objects.create(
+ enabled=True,
+ client_id='xxx',
+ client_secret='yyy',
+ platform='test',
+ scopes=['profile', 'email'],
+ )
diff --git a/tests/settings.py b/tests/settings.py
index 47b9b0d80..9153a4211 100644
--- a/tests/settings.py
+++ b/tests/settings.py
@@ -73,7 +73,7 @@ A2_VALIDATE_EMAIL_DOMAIN = False
A2_HOOKS_PROPAGATE_EXCEPTIONS = True
-TEMPLATES[0]['DIRS'].append('tests/templates') # pylint: disable=undefined-variable
+TEMPLATES[0]['DIRS'].insert(0, 'tests/templates') # pylint: disable=undefined-variable
TEMPLATES[0]['OPTIONS']['debug'] = True # pylint: disable=undefined-variable
SITE_BASE_URL = 'https://testserver'
diff --git a/tests/templates/authentic2/login_password_form.html b/tests/templates/authentic2/login_password_form.html
new file mode 100644
index 000000000..afcdeb560
--- /dev/null
+++ b/tests/templates/authentic2/login_password_form.html
@@ -0,0 +1,3 @@
+{% extends "authentic2/login_password_form.html" %}
+
+{% block login-block-title %}
Log in with Password
{% endblock %}
diff --git a/tests/templates/authentic2/login_password_registration_form.html b/tests/templates/authentic2/login_password_registration_form.html
new file mode 100644
index 000000000..cfcae085a
--- /dev/null
+++ b/tests/templates/authentic2/login_password_registration_form.html
@@ -0,0 +1,4 @@
+{% extends "authentic2/login_password_registration_form.html" %}
+{% block registration-block-title %}
+
Register with Password
+{% endblock %}
diff --git a/tests/templates/authentic2_auth_fc/login.html b/tests/templates/authentic2_auth_fc/login.html
new file mode 100644
index 000000000..000423f62
--- /dev/null
+++ b/tests/templates/authentic2_auth_fc/login.html
@@ -0,0 +1,5 @@
+{% extends "authentic2_auth_fc/login.html" %}
+
+{% block login-block-title %}
+
Log in with FC
+{% endblock %}
diff --git a/tests/templates/authentic2_auth_fc/registration.html b/tests/templates/authentic2_auth_fc/registration.html
new file mode 100644
index 000000000..ab00662d7
--- /dev/null
+++ b/tests/templates/authentic2_auth_fc/registration.html
@@ -0,0 +1,5 @@
+{% extends "authentic2_auth_fc/registration.html" %}
+
+{% block registration-block-title %}
+
Register with FC
+{% endblock %}
diff --git a/tests/test_template.py b/tests/test_template.py
index 164a840c8..59ff87424 100644
--- a/tests/test_template.py
+++ b/tests/test_template.py
@@ -16,6 +16,7 @@
import pytest
+from authentic2.utils import misc as utils_misc
from authentic2.utils.template import Template, TemplateError
pytestmark = pytest.mark.django_db
@@ -108,3 +109,18 @@ def test_render_template_missing_variable():
with pytest.raises(TemplateError) as raised:
template.render(context=context)
assert 'missing template variable' in raised
+
+
+def test_registration_with_custom_titles(app, fc):
+ url = utils_misc.make_url('registration_register')
+ response = app.get(url)
+ assert '
Registration
' not in response.text
+ assert '
Register with Password
' in response.text
+ assert '
Register with FC
' in response.text
+
+
+def test_login_with_custom_titles(app, fc):
+ url = utils_misc.make_url('auth_login')
+ response = app.get(url)
+ assert '
Log in with Password
' in response.text
+ assert '
Log in with FC
' in response.text