Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 4fa3bda3 authored by Jon Yu's avatar Jon Yu
Browse files

Add styled login template, urls

parent ccbbc76b
Pipeline #17738 passed with stage
in 13 seconds
from django.urls import reverse
from django.conf import settings
from oidc_auth.utils import using_oidc_auth
def login_url(request):
return {'LOGIN_URL': settings.LOGIN_URL}
def logout_url(request):
return {'LOGOUT_URL': reverse('oidc_logout') if using_oidc_auth() else reverse('logout')}
{% extends "base.html" %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>Your account doesn't have access to this page. To proceed,
please login with an account that has access.</p>
{% else %}
<p>Please login to see this page.</p>
{% endif %}
{% endif %}
<div class="card">
<div class="card-body">
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<div class="form-row">
<div class="form-group col-md-6">
<label for="username">Username</label>
<input class="form-control" type="text" placeholder="Username" autofocus autocapitalize="none" autocomplete="username" maxlength="150" required id="username">
</div>
<div class="form-group col-md-6">
<label for="password">Password</label>
<input class="form-control" type="password" placeholder="Password" autofocus autocomplete="current-password" required id="password">
</div>
</div>
<button type="submit" class="btn btn-primary">Login</button>
<input type="hidden" name="next" value="{{ next }}">
</form>
</div>
<div class="card-footer">
<a href="{% url 'password_reset' %}">Lost password?</a>
</div>
</div>
{% endblock %}
......@@ -7,5 +7,5 @@ urlpatterns = [
url(r'^oidc/', include('mozilla_django_oidc.urls')),
]
if using_oidc_auth():
if not using_oidc_auth():
urlpatterns += [path('accounts/', include('django.contrib.auth.urls'))]
......@@ -93,6 +93,8 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'oidc_auth.context_processors.login_url',
'oidc_auth.context_processors.logout_url',
],
},
},
......@@ -109,12 +111,10 @@ AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
]
LOGIN_URL = '/accounts/login/'
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = os.getenv('LOGOUT_REDIRECT_URL', '/')
if DEBUG is True:
LOGIN_URL = '/admin'
# Mozilla OIDC
# https://mozilla-django-oidc.readthedocs.io/en/stable/
......
......@@ -30,15 +30,15 @@
<a class="nav-link dropdown-toggle" href="#" id="userMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ request.user.username }}
</a>
<div class="dropdown-menu" aria-labelledby="userMenu">
<form action="{% url 'oidc_logout' %}" method="post">
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userMenu">
<form action="{{ LOGOUT_URL }}" method="post">
{% csrf_token %}
<input type="submit" value="logout" style="background-color: white" class="dropdown-item">
</form>
</div>
</li>
{% else %}
<a href="{% url 'oidc_authentication_init' %}" class="nav-link">Login</a>
<a href="{{ LOGIN_URL }}" class="nav-link">Login</a>
{% endif %}
</div>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment