misc: use the django authentication system
This commit is contained in:
		@ -71,6 +71,11 @@ Usefull context:
 | 
			
		||||
                            {% translate "Admin" %}
 | 
			
		||||
                        </a>
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                        {% 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 %}
 | 
			
		||||
                        {% endblock %}
 | 
			
		||||
                    </div>
 | 
			
		||||
                    {% endblock %}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								aircox/templates/registration/login.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								aircox/templates/registration/login.html
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
{% extends "aircox/base.html" %}
 | 
			
		||||
{% load i18n aircox %}
 | 
			
		||||
 | 
			
		||||
{% block content-container %}
 | 
			
		||||
<div class="container content page-content">
 | 
			
		||||
<h2>{% trans "Log in" %}</h2>
 | 
			
		||||
<br/>
 | 
			
		||||
<form method="post" action="{% url 'login' %}">
 | 
			
		||||
  {% csrf_token %}
 | 
			
		||||
  <table>
 | 
			
		||||
  {{ form.as_table }}
 | 
			
		||||
  </table>
 | 
			
		||||
  <br/>
 | 
			
		||||
  <button class="button" type="submit">{% trans "Log in" %}</button>
 | 
			
		||||
  <input type="hidden" name="next" value="{{ next }}">
 | 
			
		||||
</form>
 | 
			
		||||
</div>
 | 
			
		||||
{% 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")
 | 
			
		||||
@ -250,3 +250,5 @@ TEMPLATES = [
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
WSGI_APPLICATION = "instance.wsgi.application"
 | 
			
		||||
 | 
			
		||||
LOGOUT_REDIRECT_URL = "/"
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,7 @@ import aircox.urls
 | 
			
		||||
 | 
			
		||||
urlpatterns = aircox.urls.urls + [
 | 
			
		||||
    path("admin/", admin.site.urls),
 | 
			
		||||
    path("accounts/", include("django.contrib.auth.urls")),
 | 
			
		||||
    path("ckeditor/", include("ckeditor_uploader.urls")),
 | 
			
		||||
    path("filer/", include("filer.urls")),
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user