From 63e6a6bdfdf813d1db891085ed0f4dc495de0eb0 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 11 Mar 2021 14:49:29 +0100 Subject: [PATCH] added simple auth --- eva/urls.py | 1 + evapp/templates/registration/login.html | 35 +++++++++++++++++++++++++ evapp/views.py | 3 ++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 evapp/templates/registration/login.html diff --git a/eva/urls.py b/eva/urls.py index 9417d51..d243e82 100644 --- a/eva/urls.py +++ b/eva/urls.py @@ -19,4 +19,5 @@ from django.urls import path, include urlpatterns = [ path('', include("evapp.urls")), path('admin/', admin.site.urls), + path('accounts/', include('django.contrib.auth.urls')), ] diff --git a/evapp/templates/registration/login.html b/evapp/templates/registration/login.html new file mode 100644 index 0000000..cbceed1 --- /dev/null +++ b/evapp/templates/registration/login.html @@ -0,0 +1,35 @@ +{% 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 login to see this page.

+ {% endif %} + {% endif %} + +
+ {% csrf_token %} + + + + + + + + + +
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
+ + +
+ + {# Assumes you setup the password_reset view in your URLconf #} +

Lost password?

+ +{% endblock %} diff --git a/evapp/views.py b/evapp/views.py index 1227fc6..9e4fd76 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -9,6 +9,7 @@ from django.template.loader import get_template from formtools.wizard.views import CookieWizardView from django.shortcuts import render from django.conf import settings +from django.contrib.auth.mixins import LoginRequiredMixin from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES, VENDOR_CHOICES, \ MOBILE_CHOICES, LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES @@ -43,7 +44,7 @@ def change_process(wizard): return not long_process(wizard) -class EvaFormView(CookieWizardView): +class EvaFormView(LoginRequiredMixin, CookieWizardView): template_name = 'evapp/employee_form.html' form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, ChangeForm, DummyForm] instance = None