misc: use the django authentication system
This commit is contained in:
parent
d63d949096
commit
291949e6e8
|
@ -68,6 +68,7 @@ Usefull context:
|
||||||
<div class="navbar-end">
|
<div class="navbar-end">
|
||||||
{% block top-nav-tools %}
|
{% block top-nav-tools %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block top-nav-end %}
|
{% block top-nav-end %}
|
||||||
<div class="navbar-item">
|
<div class="navbar-item">
|
||||||
<form action="{% url 'page-list' %}" method="GET">
|
<form action="{% url 'page-list' %}" method="GET">
|
||||||
|
@ -81,6 +82,12 @@ Usefull context:
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<div class="navbar-item">
|
||||||
|
<a>{{ user.username }}</a> <a href="{% url 'logout' %}"> <i class="fa fa-power-off"></i></a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
20
aircox/templates/registration/login.html
Normal file
20
aircox/templates/registration/login.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "aircox/base.html" %}
|
||||||
|
{% load i18n aircox %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<h2>{% trans "Log in" %}</h2>
|
||||||
|
<br/>
|
||||||
|
<form method="post" action="{% url 'login' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<table>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
<button type="submit">{% trans "Log in" %}</button>
|
||||||
|
<input type="hidden" name="next" value="{{ next }}">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{ block.super }}
|
||||||
|
|
||||||
|
{% endblock %}
|
12
aircox/tests/test_profile.py
Normal file
12
aircox/tests/test_profile.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import pytest
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db()
|
||||||
|
def test_authenticate(user, client, program):
|
||||||
|
r = client.get(reverse("login"))
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert b"id_username" in r.content
|
||||||
|
r = client.post(reverse("login"), kwargs={"username": "foo", "password": "bar"})
|
||||||
|
assert b"errorlist" in r.content
|
||||||
|
assert client.login(username="user1", password="bar")
|
|
@ -249,3 +249,5 @@ TEMPLATES = [
|
||||||
|
|
||||||
|
|
||||||
WSGI_APPLICATION = "instance.wsgi.application"
|
WSGI_APPLICATION = "instance.wsgi.application"
|
||||||
|
|
||||||
|
LOGOUT_REDIRECT_URL = "/"
|
||||||
|
|
|
@ -23,6 +23,7 @@ import aircox.urls
|
||||||
|
|
||||||
urlpatterns = aircox.urls.urls + [
|
urlpatterns = aircox.urls.urls + [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
|
path("accounts/", include("django.contrib.auth.urls")),
|
||||||
path("ckeditor/", include("ckeditor_uploader.urls")),
|
path("ckeditor/", include("ckeditor_uploader.urls")),
|
||||||
path("filer/", include("filer.urls")),
|
path("filer/", include("filer.urls")),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user