Add LoginRequiredMixin mixin for various views
This commit is contained in:
parent
0591a186d8
commit
c3b8f7b553
2 changed files with 7 additions and 5 deletions
|
@ -16,5 +16,5 @@ urlpatterns = [
|
||||||
path('logout/', LogOut.as_view(), name="logout"),
|
path('logout/', LogOut.as_view(), name="logout"),
|
||||||
path('reset/<str:user>/<str:token>/', ResetRequest.as_view()),
|
path('reset/<str:user>/<str:token>/', ResetRequest.as_view()),
|
||||||
path('reset/', ResetRequest.as_view(), name="reset"),
|
path('reset/', ResetRequest.as_view(), name="reset"),
|
||||||
path('', Index.as_view(), name="index"),
|
path('', Index.as_view(), name="login_index"),
|
||||||
]
|
]
|
10
dal/views.py
10
dal/views.py
|
@ -27,6 +27,7 @@ import ldap
|
||||||
import ldap.modlist as modlist
|
import ldap.modlist as modlist
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
|
||||||
|
|
||||||
class Index(FormView):
|
class Index(FormView):
|
||||||
|
@ -93,7 +94,7 @@ class Register(View):
|
||||||
|
|
||||||
return render(request, 'usercreated.html', { 'user': username } )
|
return render(request, 'usercreated.html', { 'user': username } )
|
||||||
|
|
||||||
class ChangeData(View):
|
class ChangeData(LoginRequiredMixin, View):
|
||||||
# provide the form for the change request
|
# provide the form for the change request
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
urlname = 'change_data'
|
urlname = 'change_data'
|
||||||
|
@ -166,7 +167,8 @@ class ChangeData(View):
|
||||||
return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': msg } )
|
return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': msg } )
|
||||||
|
|
||||||
|
|
||||||
class ResetPassword(View):
|
class ResetPassword(LoginRequiredMixin, View):
|
||||||
|
login_url = reverse_lazy('login_index')
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
return render(request, 'resetpassword.html')
|
return render(request, 'resetpassword.html')
|
||||||
|
|
||||||
|
@ -339,7 +341,7 @@ class ResetRequest(View):
|
||||||
|
|
||||||
# The logged in user can change the password here
|
# The logged in user can change the password here
|
||||||
|
|
||||||
class ChangePassword(View):
|
class ChangePassword(LoginRequiredMixin, View):
|
||||||
|
|
||||||
# Presents the page for a logged in user
|
# Presents the page for a logged in user
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
|
@ -389,7 +391,7 @@ class ChangePassword(View):
|
||||||
|
|
||||||
|
|
||||||
# Deletes an account
|
# Deletes an account
|
||||||
class DeleteAccount(View):
|
class DeleteAccount(LoginRequiredMixin, View):
|
||||||
# Show the basic form for deleting an account
|
# Show the basic form for deleting an account
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
return render(request, 'deleteaccount.html')
|
return render(request, 'deleteaccount.html')
|
||||||
|
|
Loading…
Reference in a new issue