Commit 13c73592 authored by Valentin Samir's avatar Valentin Samir

Remember warn using a cookie

parent aae3a018
...@@ -87,13 +87,13 @@ class FederateSelect(BaseLogin): ...@@ -87,13 +87,13 @@ class FederateSelect(BaseLogin):
to_field_name="suffix", to_field_name="suffix",
label=_('Identity provider'), label=_('Identity provider'),
) )
#: A checkbox to remember the user choices of :attr:`provider<FederateSelect.provider>`
remember = forms.BooleanField(label=_('Remember the identity provider'), required=False)
#: A checkbox to ask to be warn before emiting a ticket for another service #: A checkbox to ask to be warn before emiting a ticket for another service
warn = forms.BooleanField( warn = forms.BooleanField(
label=_('Warn me before logging me into other sites.'), label=_('Warn me before logging me into other sites.'),
required=False required=False
) )
#: A checkbox to remember the user choices of :attr:`provider<FederateSelect.provider>`
remember = forms.BooleanField(label=_('Remember the identity provider'), required=False)
class UserCredential(BaseLogin): class UserCredential(BaseLogin):
......
...@@ -498,7 +498,17 @@ class LoginView(View, LogoutMixin): ...@@ -498,7 +498,17 @@ class LoginView(View, LogoutMixin):
else: # pragma: no cover (should no happen) else: # pragma: no cover (should no happen)
raise EnvironmentError("invalid output for LoginView.process_post") raise EnvironmentError("invalid output for LoginView.process_post")
# call the GET/POST common part # call the GET/POST common part
return self.common() response = self.common()
if self.warn:
utils.set_cookie(
response,
"warn",
"on",
10 * 365 * 24 * 3600
)
else:
response.delete_cookie("warn")
return response
def process_post(self): def process_post(self):
""" """
...@@ -607,7 +617,9 @@ class LoginView(View, LogoutMixin): ...@@ -607,7 +617,9 @@ class LoginView(View, LogoutMixin):
form_initial = { form_initial = {
'service': self.service, 'service': self.service,
'method': self.method, 'method': self.method,
'warn': self.warn or self.request.session.get("warn"), 'warn': (
self.warn or self.request.session.get("warn") or self.request.COOKIES.get('warn')
),
'lt': self.request.session['lt'][-1], 'lt': self.request.session['lt'][-1],
'renew': self.renew 'renew': self.renew
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment