Skip to content
Snippets Groups Projects
Verified Commit 4d8b48a3 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Allow apps to add custom auth views and allow users to select them on login page

parent bb44a920
No related branches found
No related tags found
1 merge request!334Resolve "Support custom authentication backends"
Pipeline #3070 failed
......@@ -288,6 +288,10 @@ merge_app_settings("AUTHENTICATION_BACKENDS", AUTHENTICATION_BACKENDS)
# to verify passwords first
AUTHENTICATION_BACKENDS.append("django.contrib.auth.backends.ModelBackend")
# Structure of items: URL name, icon name, button title
ALTERNATIVE_LOGIN_VIEWS = []
merge_app_settings("ALTERNATIVE_LOGIN_VIEWS", ALTERNATIVE_LOGIN_VIEWS, True)
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
......@@ -382,7 +386,7 @@ TEMPLATED_EMAIL_BACKEND = "templated_email.backends.vanilla_django"
TEMPLATED_EMAIL_AUTO_PLAIN = True
TEMPLATE_VISIBLE_SETTINGS = ["ADMINS", "DEBUG"]
TEMPLATE_VISIBLE_SETTINGS = ["ADMINS", "DEBUG", "ALTERNATIVE_LOGIN_VIEWS"]
DYNAMIC_PREFERENCES = {
"REGISTRY_MODULE": "preferences",
......
{% if ALTERNATIVE_LOGIN_VIEWS %}
<p>
{% for url, icon, text in ALTERNATIVE_LOGIN_VIEWS %}
<a class="btn-large waves-effect waves-light primary" href="{% url url %}">
<i class="material-icons left">{{ icon }}</i>
{{ text }}
</a>
{% endfor %}
</p>
{% endif %}
......@@ -16,14 +16,26 @@
{% blocktrans %}You have no permission to view this page. Please login with an other account.{% endblocktrans %}
</p>
</div>
{% else %}
{% elif wizard.steps.current == 'auth' %}
<div class="alert primary">
<p>
<i class="material-icons left">info</i>
{% if wizard.steps.current == 'auth' %}
{% blocktrans %}Please login to see this page.{% endblocktrans %}
{% elif wizard.steps.current == 'token' %}
{% blocktrans %}Please login to see this page.{% endblocktrans %}
</p>
</div>
{% endif %}
{% if wizard.steps.current == 'auth' and ALTERNATIVE_LOGIN_VIEWS %}
<h5>{% trans "Login with username and password" %}</h5>
{% endif %}
{% if not wizard.steps.current == "auth" %}
<div class="alert primary">
<p>
<i class="material-icons left">info</i>
{% if wizard.steps.current == 'token' %}
{% if device.method == 'call' %}
{% blocktrans %}We are calling your phone right now, please enter the
digits you hear.{% endblocktrans %}
......@@ -70,7 +82,16 @@
</p>
{% endif %}
<button type="submit" class="btn green waves-effect waves-light">{% trans "Login" %}</button>
<button type="submit" class="btn green waves-effect waves-light">
{% trans "Login" %}
<i class="material-icons right">send</i>
</button>
</form>
{% if wizard.steps.current == 'auth' and ALTERNATIVE_LOGIN_VIEWS %}
<h5>{% trans "Use alternative login options" %}</h5>
{% include "core/partials/alternative_login_options.html" %}
{% endif %}
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment