fix UserChangePasswordView not requiring Login
This commit is contained in:
parent
2690675dca
commit
e1f1f617b6
|
@ -1,6 +1,7 @@
|
||||||
"""passbook core user views"""
|
"""passbook core user views"""
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth import logout, update_session_auth_hash
|
from django.contrib.auth import logout, update_session_auth_hash
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.forms.utils import ErrorList
|
from django.forms.utils import ErrorList
|
||||||
from django.shortcuts import redirect, reverse
|
from django.shortcuts import redirect, reverse
|
||||||
|
@ -13,7 +14,7 @@ from passbook.core.forms.users import PasswordChangeForm, UserDetailForm
|
||||||
from passbook.lib.config import CONFIG
|
from passbook.lib.config import CONFIG
|
||||||
|
|
||||||
|
|
||||||
class UserSettingsView(SuccessMessageMixin, UpdateView):
|
class UserSettingsView(SuccessMessageMixin, LoginRequiredMixin, UpdateView):
|
||||||
"""Update User settings"""
|
"""Update User settings"""
|
||||||
|
|
||||||
template_name = 'user/settings.html'
|
template_name = 'user/settings.html'
|
||||||
|
@ -25,7 +26,8 @@ class UserSettingsView(SuccessMessageMixin, UpdateView):
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.request.user
|
return self.request.user
|
||||||
|
|
||||||
class UserDeleteView(DeleteView):
|
|
||||||
|
class UserDeleteView(LoginRequiredMixin, DeleteView):
|
||||||
"""Delete user account"""
|
"""Delete user account"""
|
||||||
|
|
||||||
template_name = 'generic/delete.html'
|
template_name = 'generic/delete.html'
|
||||||
|
@ -38,7 +40,8 @@ class UserDeleteView(DeleteView):
|
||||||
logout(self.request)
|
logout(self.request)
|
||||||
return reverse('passbook_core:auth-login')
|
return reverse('passbook_core:auth-login')
|
||||||
|
|
||||||
class UserChangePasswordView(FormView):
|
|
||||||
|
class UserChangePasswordView(LoginRequiredMixin, FormView):
|
||||||
"""View for users to update their password"""
|
"""View for users to update their password"""
|
||||||
|
|
||||||
form_class = PasswordChangeForm
|
form_class = PasswordChangeForm
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""passbook core utils view"""
|
"""passbook core utils view"""
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class LoadingView(TemplateView):
|
||||||
kwargs['target_url'] = self.get_url()
|
kwargs['target_url'] = self.get_url()
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
|
||||||
class PermissionDeniedView(TemplateView):
|
class PermissionDeniedView(LoginRequiredMixin, TemplateView):
|
||||||
"""Generic Permission denied view"""
|
"""Generic Permission denied view"""
|
||||||
|
|
||||||
template_name = 'login/denied.html'
|
template_name = 'login/denied.html'
|
||||||
|
|
Reference in New Issue