misc: use the django authentication system
This commit is contained in:
@ -68,6 +68,7 @@ Usefull context:
|
||||
<div class="navbar-end">
|
||||
{% block top-nav-tools %}
|
||||
{% endblock %}
|
||||
|
||||
{% block top-nav-end %}
|
||||
<div class="navbar-item">
|
||||
<form action="{% url 'page-list' %}" method="GET">
|
||||
@ -81,6 +82,12 @@ Usefull context:
|
||||
</form>
|
||||
</div>
|
||||
{% 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>
|
||||
|
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")
|
Reference in New Issue
Block a user