diff --git a/app/authentication/__init__.py b/app/authentication/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/authentication/admin.py b/app/authentication/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/app/authentication/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/authentication/apps.py b/app/authentication/apps.py new file mode 100644 index 0000000..8bab8df --- /dev/null +++ b/app/authentication/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AuthenticationConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'authentication' diff --git a/app/authentication/forms.py b/app/authentication/forms.py new file mode 100644 index 0000000..e69de29 diff --git a/app/authentication/migrations/__init__.py b/app/authentication/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/authentication/models.py b/app/authentication/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/app/authentication/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/app/authentication/templates/authentication/login.html b/app/authentication/templates/authentication/login.html new file mode 100644 index 0000000..f735a2e --- /dev/null +++ b/app/authentication/templates/authentication/login.html @@ -0,0 +1,39 @@ +{% extends 'core/base.html' %} +{% block content %} +
+ {% if form.errors %} +
+

Your username and password didn't match. Please try again.

+
+ {% endif %} + + {% if next %} +
+ {% if user.is_authenticated %} +

Your account doesn't have access to this page. To proceed, + please login with an account that has access.

+ {% else %} +

Please log in to see this page.

+ {% endif %} +
+ {% endif %} + +
+ {% csrf_token %} +
+ Please enter your login details +
+
{{ form.username.label_tag }}
+
{{ form.username }}
+
{{ form.password.label_tag }}
+
{{ form.password }}
+ +
+ +
+
+ + {# Assumes you set up the password_reset view in your URLconf #} + {% comment %}

Lost password?

{% endcomment %} +
+{% endblock content %} diff --git a/app/authentication/templates/authentication/logout.html b/app/authentication/templates/authentication/logout.html new file mode 100644 index 0000000..8f2e9bf --- /dev/null +++ b/app/authentication/templates/authentication/logout.html @@ -0,0 +1,4 @@ +{% extends 'core/base.html' %} +{% block content %} +

You have been logged out.

+{% endblock content %} diff --git a/app/authentication/tests.py b/app/authentication/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/authentication/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/authentication/urls.py b/app/authentication/urls.py new file mode 100644 index 0000000..37f71ff --- /dev/null +++ b/app/authentication/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from django.contrib.auth import views as auth_views + +urlpatterns = [ + path("login/", auth_views.LoginView.as_view(template_name="authentication/login.html"), name="login"), + path("logout/", auth_views.LogoutView.as_view(template_name="authentication/logout.html"), name="logout"), +] diff --git a/app/authentication/views.py b/app/authentication/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/app/authentication/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/app/core/settings.py b/app/core/settings.py index 39dc756..651f311 100644 --- a/app/core/settings.py +++ b/app/core/settings.py @@ -32,6 +32,8 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'core', + 'authentication.apps.AuthenticationConfig', 'medwings.apps.MedwingsConfig', 'django.contrib.admin', 'django.contrib.auth', @@ -104,6 +106,9 @@ AUTH_PASSWORD_VALIDATORS = [ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] +LOGIN_REDIRECT_URL = 'home' +LOGIN_URL = 'login' +LOGOUT_REDIRECT_URL = 'home' # Internationalization diff --git a/app/medwings/templates/medwings/base.html b/app/core/templates/core/base.html similarity index 90% rename from app/medwings/templates/medwings/base.html rename to app/core/templates/core/base.html index a9b7547..b616794 100644 --- a/app/medwings/templates/medwings/base.html +++ b/app/core/templates/core/base.html @@ -13,14 +13,14 @@
- {% include 'medwings/navbar.html' %} + {% include 'core/navbar.html' %}
{% block content %} {% endblock content %}
diff --git a/app/core/templates/core/footer.html b/app/core/templates/core/footer.html new file mode 100644 index 0000000..0022947 --- /dev/null +++ b/app/core/templates/core/footer.html @@ -0,0 +1,3 @@ +
+

© 2023 Julian Lobbes

+
diff --git a/app/medwings/templates/medwings/navbar.html b/app/core/templates/core/navbar.html similarity index 92% rename from app/medwings/templates/medwings/navbar.html rename to app/core/templates/core/navbar.html index d46340d..c535a34 100644 --- a/app/medwings/templates/medwings/navbar.html +++ b/app/core/templates/core/navbar.html @@ -1,4 +1,4 @@ -