Add a logout template and possibility to redirect to login on logout
This commit is contained in:
parent
54f9b7c50c
commit
f73e55b5ce
4 changed files with 28 additions and 3 deletions
|
@ -13,7 +13,7 @@ are listed in default_settings.py
|
|||
|
||||
The defaut login/logout template use `django-bootstrap3 <https://github.com/dyve/django-bootstrap3>`_
|
||||
but you can use your own templates using the CAS_LOGIN_TEMPLATE,
|
||||
CAS_LOGGED_TEMPLATE and CAS_WARN_TEMPLATE setting variables.
|
||||
CAS_LOGGED_TEMPLATE, CAS_WARN_TEMPLATE and CAS_LOGOUT_TEMPLATEsetting variables.
|
||||
|
||||
Quick start
|
||||
-----------
|
||||
|
|
|
@ -19,11 +19,13 @@ def setting_default(name, default_value):
|
|||
setting_default('CAS_LOGIN_TEMPLATE', 'cas_server/login.html')
|
||||
setting_default('CAS_WARN_TEMPLATE', 'cas_server/warn.html')
|
||||
setting_default('CAS_LOGGED_TEMPLATE', 'cas_server/logged.html')
|
||||
setting_default('CAS_LOGOUT_TEMPLATE', 'cas_server/logout.html')
|
||||
setting_default('CAS_AUTH_CLASS', 'cas_server.auth.DjangoAuthUser')
|
||||
setting_default('CAS_ST_LEN', 30)
|
||||
setting_default('CAS_TICKET_VALIDITY', 300)
|
||||
setting_default('CAS_TICKET_TIMEOUT', 24*3600)
|
||||
setting_default('CAS_PROXY_CA_CERTIFICATE_PATH', True)
|
||||
setting_default('CAS_REDIRECT_TO_LOGIN_AFTER_LOGOUT', False)
|
||||
|
||||
setting_default('CAS_SERVICE_TICKET_PREFIX', 'ST')
|
||||
setting_default('CAS_PROXY_TICKET_PREFIX', 'PT')
|
||||
|
|
20
cas_server/templates/cas_server/logout.html
Normal file
20
cas_server/templates/cas_server/logout.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
{% extends "cas_server/base.html" %}
|
||||
{% load bootstrap3 %}
|
||||
{% load staticfiles %}
|
||||
{% load i18n %}
|
||||
{% block bootstrap3_extra_head %}
|
||||
<link href="{% static "cas_server/login.css" %}" rel="stylesheet">
|
||||
{% endblock %}
|
||||
{% block bootstrap3_content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-6">
|
||||
{% bootstrap_messages %}
|
||||
<div class="alert alert-success" role="alert">{% trans "Successfully logout" %}</div>
|
||||
</div>
|
||||
<div class="col-md-3"></div>
|
||||
</div>
|
||||
</div> <!-- /container -->
|
||||
{% endblock %}
|
||||
|
|
@ -91,8 +91,11 @@ class LogoutView(View, LogoutMixin):
|
|||
return HttpResponseRedirect(self.service)
|
||||
# else redirect to login page
|
||||
else:
|
||||
messages.add_message(request, messages.SUCCESS, _(u'Successfully logout'))
|
||||
return redirect("cas_server:login")
|
||||
if settings.CAS_REDIRECT_TO_LOGIN_AFTER_LOGOUT:
|
||||
messages.add_message(request, messages.SUCCESS, _(u'Successfully logout'))
|
||||
return redirect("cas_server:login")
|
||||
else:
|
||||
return render(request, settings.CAS_LOGOUT_TEMPLATE)
|
||||
|
||||
class LoginView(View, LogoutMixin):
|
||||
"""credential requestor / acceptor"""
|
||||
|
|
Loading…
Reference in a new issue