Authentification CAS par défaut, permet de choisir entre CAS et mdp lorsque la variable election
exite dans le template
This commit is contained in:
parent
fc695b9cc5
commit
416efd5267
7 changed files with 104 additions and 5 deletions
|
@ -5,7 +5,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
|
||||
|
||||
class ElectionAuthForm(forms.Form):
|
||||
"""Adapts Django's AuthenticationForm to allow for OldCAS login."""
|
||||
"""Adapts Django's AuthenticationForm to allow for an election specific login."""
|
||||
|
||||
login = auth_forms.UsernameField(label=_("Identifiant"), max_length=255)
|
||||
password = forms.CharField(label=_("Mot de passe"), strip=False)
|
||||
|
@ -17,7 +17,7 @@ class ElectionAuthForm(forms.Form):
|
|||
super().__init__(*args, **kwargs)
|
||||
|
||||
def clean(self):
|
||||
login = self.cleaned_data.get("cas_login")
|
||||
login = self.cleaned_data.get("login")
|
||||
password = self.cleaned_data.get("password")
|
||||
election_id = self.cleaned_data.get("election_id")
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ class LoginSelectView(NextPageMixin, TemplateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["next"] = self.get_next_url()
|
||||
context["method"] = self.request.GET.get("method", "CAS")
|
||||
context["election_id"] = self.request.GET.get("election_id", None)
|
||||
|
||||
return context
|
||||
|
||||
|
@ -82,7 +84,7 @@ class PasswordLoginView(auth_views.LoginView):
|
|||
authentication_form = ElectionAuthForm
|
||||
|
||||
def get_initial(self):
|
||||
return {"election_id": self.request.GET.get("election", None)}
|
||||
return {"election_id": self.request.GET.get("election_id", None)}
|
||||
|
||||
|
||||
class LogoutView(auth_views.LogoutView):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue