Files
fet2020/fet2020/authentications/views.py

44 lines
1.1 KiB
Python

from django.contrib.auth import logout
from django.contrib.auth.views import (
LoginView,
PasswordChangeDoneView,
PasswordChangeView,
)
from django.shortcuts import redirect
from django.urls import reverse, reverse_lazy
from documents.etherpadlib import del_ep_cookie
from .decorators import authenticated_user
from .forms import LdapPasswordChangeForm, LoginForm
class AuthLoginView(LoginView):
authentication_form = LoginForm
redirect_authenticated_user = True
template_name = "authentications/login.html"
@authenticated_user
def logoutUser(request):
logout(request)
try:
response = redirect(request.GET.get("next"))
except:
response = redirect("home")
response = del_ep_cookie(request, response)
return response
class LdapPasswordChangeView(PasswordChangeView):
form_class = LdapPasswordChangeForm
success_url = reverse_lazy("authentications:password_change_done")
template_name = "authentications/change_password.html"
class LdapPasswordChangeDoneView(PasswordChangeDoneView):
template_name = "authentications/change_password_done.html"