idp: wait for all iframe onload event before doing local logout

This commit is contained in:
Benjamin Dauvergne 2013-12-09 16:43:22 +01:00
parent f875685be8
commit e447544249
3 changed files with 14 additions and 3 deletions

View File

@ -66,7 +66,7 @@ class AuthSAML2Backend:
code = '<div>'
code += _('Sending logout to %(pid)s....') % { 'pid': name or provider_id }
code += '<iframe src="%s?provider_id=%s" marginwidth="0" marginheight="0" \
scrolling="no" style="border: none" width="16" height="16"></iframe></div>' \
scrolling="no" style="border: none" width="16" height="16" onload="iframe_count -= 1"></iframe></div>' \
% (reverse(saml2_endpoints.sp_slo,
args=[provider_id]), provider_id)
return [ code ]

View File

@ -62,7 +62,7 @@ class SamlBackend(object):
code = '<div>'
code += _('Sending logout to %(name)s....') % { 'name': name or provider_id}
code += '<iframe src="%s?provider_id=%s" marginwidth="0" marginheight="0" \
scrolling="no" style="border: none" width="16" height="16"></iframe></div>' % \
scrolling="no" style="border: none" width="16" height="16" onload="iframe_count -= 1"></iframe></div>' % \
(reverse(saml2_endpoints.idp_slo, args=[provider_id]), provider_id)
logger.debug("logout_list: code %r" % code)
result.append(code)

View File

@ -4,9 +4,11 @@
{% block title %}
{% trans "Logout" %}
{% endblock %}
{% block bodyargs %}onload="setTimeout(function () {window.location='{{ next_page }}'}, {{ redir_timeout }})"{% endblock %}
{% block content %}
<script>
var iframe_count = 0;
</script>
<h1>{% trans message %}</h1>
<ul class="logout-list">
@ -15,6 +17,15 @@
{% endfor %}
</ul>
<script>
iframe_count += document.getElementsByTagName("iframe").length;
setInterval(function () {
if (iframe_count == 0) {
window.location = '{{ next_page }}';
}
}, {{ redir_timeout }})
</script>
<div id="continue-link"><a href="{{ next_page }}">{% trans "Continue logout" %}</div>
{% endblock %}