core: add temporary login form with support for sources

This commit is contained in:
Jens Langhammer 2018-12-18 13:26:14 +01:00
parent b0fa302718
commit 8383df2441
3 changed files with 58 additions and 2 deletions

View File

@ -26,7 +26,7 @@
<div class="login-pf-page"> <div class="login-pf-page">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4"> <div class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3 col-lg-6 col-lg-offset-3">
<header class="login-pf-page-header"> <header class="login-pf-page-header">
<img class="login-pf-brand" style="max-height: 10rem;" src="{% static 'img/logo.svg' %}" alt="PatternFly logo" /> <img class="login-pf-brand" style="max-height: 10rem;" src="{% static 'img/logo.svg' %}" alt="PatternFly logo" />
{% if config.login.subtext %} {% if config.login.subtext %}
@ -34,6 +34,7 @@
{% endif %} {% endif %}
</header> </header>
<div class="row"> <div class="row">
{% block row %}
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2"> <div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2">
<div class="card-pf"> <div class="card-pf">
{% block card %} {% block card %}
@ -47,6 +48,7 @@
</ul> </ul>
</footer> </footer>
</div><!-- col --> </div><!-- col -->
{% endblock %}
</div><!-- row --> </div><!-- row -->
</div><!-- col --> </div><!-- col -->
</div><!-- row --> </div><!-- row -->

View File

@ -0,0 +1,51 @@
{% extends 'login/base.html' %}
{% load static %}
{% load i18n %}
{% block row %}
{% include 'partials/messages.html' %}
<div class="col-md-6">
<div class="card-pf">
<header class="login-pf-header">
<h1>{% trans title %}</h1>
</header>
<form method="POST">
{% csrf_token %}
{% block above_form %}
{% endblock %}
{% include 'partials/form_login.html' %}
<button type="submit" class="btn btn-primary btn-block btn-lg">{% trans primary_action %}</button>
</form>
{% if show_sign_up_notice %}
<p class="login-pf-signup">
{% trans 'Need an account?' %}
<a href="{% url 'passbook_core:auth-sign-up' %}">{% trans 'Sign up' %}</a>
</p>
{% endif %}
</div>
</div>
<div class="col-md-6">
<div class="card-pf">
<header class="login-pf-header">
<h1>{% trans title %}</h1>
<ul>
{% for source in sources %}
<li>
<a class="btn btn-block btn-primary" href="{{ source.get_url }}">{{ source }}</a>
</li>
{% endfor %}
</ul>
</header>
</div>
</div>
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2">
<footer class="login-pf-page-footer">
<ul class="login-pf-page-footer-links list-unstyled">
<li><a class="login-pf-page-footer-link" href="#">Terms of Use</a></li>
<li><a class="login-pf-page-footer-link" href="#">Help</a></li>
<li><a class="login-pf-page-footer-link" href="#">Privacy Policy</a></li>
</ul>
</footer>
</div>
{% endblock %}

View File

@ -13,7 +13,7 @@ from django.views.generic import FormView
from passbook.core.auth.mfa import MultiFactorAuthenticator from passbook.core.auth.mfa import MultiFactorAuthenticator
from passbook.core.forms.authentication import LoginForm, SignUpForm from passbook.core.forms.authentication import LoginForm, SignUpForm
from passbook.core.models import Invitation, User from passbook.core.models import Invitation, Source, User
from passbook.core.signals import invitation_used, user_signed_up from passbook.core.signals import invitation_used, user_signed_up
from passbook.lib.config import CONFIG from passbook.lib.config import CONFIG
@ -42,6 +42,9 @@ class LoginView(UserPassesTestMixin, FormView):
kwargs['primary_action'] = _('Log in') kwargs['primary_action'] = _('Log in')
kwargs['show_sign_up_notice'] = CONFIG.y('passbook.sign_up.enabled') kwargs['show_sign_up_notice'] = CONFIG.y('passbook.sign_up.enabled')
kwargs['show_password_forget_notice'] = CONFIG.y('passbook.password_reset.enabled') kwargs['show_password_forget_notice'] = CONFIG.y('passbook.password_reset.enabled')
kwargs['sources'] = Source.objects.filter(enabled=True).select_subclasses()
if any(source.is_link for source in kwargs['sources']):
self.template_name = 'login/with_sources.html'
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)
def get_user(self, uid_value) -> User: def get_user(self, uid_value) -> User: