summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-10-13 23:41:12 -0400
committerPatrick Uiterwijk <puiterwijk@redhat.com>2014-10-24 18:03:28 +0200
commitd597f362db9012a47164369e7614fd6a2060e7e5 (patch)
treea6ba342eefbe4c2d40f077fdcdcfb853934b192d
parentfe50fd3423969fca640cc35b32678bab5fd491cb (diff)
Return to provider if user cancels login
When the cancel button is hit return to the provider and eventually to the original application via return urls. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
-rwxr-xr-xipsilon/login/common.py22
-rw-r--r--templates/login/form.html6
2 files changed, 27 insertions, 1 deletions
diff --git a/ipsilon/login/common.py b/ipsilon/login/common.py
index cb45fd6..6cd1ca8 100755
--- a/ipsilon/login/common.py
+++ b/ipsilon/login/common.py
@@ -226,6 +226,8 @@ class LoginFormBase(LoginPageBase):
"next_url": next_url,
"username": username,
"login_target": target,
+ "cancel_url": '%s/login/cancel?%s' % (self.basepath,
+ self.trans.get_GET_arg()),
}
context.update(kwargs)
if self.trans is not None:
@@ -242,6 +244,7 @@ class Login(Page):
def __init__(self, *args, **kwargs):
super(Login, self).__init__(*args, **kwargs)
+ self.cancel = Cancel(*args, **kwargs)
self.first_login = None
self.info = Info(self._site)
@@ -279,6 +282,25 @@ class Logout(Page):
return self._template('logout.html', title='Logout')
+class Cancel(Page):
+
+ def GET(self, *args, **kwargs):
+
+ session = UserSession()
+ session.logout(None)
+
+ # return to the caller if any
+ transdata = self.get_valid_transaction('login', **kwargs).retrieve()
+ if 'login_return' not in transdata:
+ raise cherrypy.HTTPError(401)
+ raise cherrypy.HTTPRedirect(transdata['login_return'])
+
+ def root(self, *args, **kwargs):
+ op = getattr(self, cherrypy.request.method, self.GET)
+ if callable(op):
+ return op(*args, **kwargs)
+
+
class LoginMgrsInstall(object):
def __init__(self):
diff --git a/templates/login/form.html b/templates/login/form.html
index e5e5978..69a0cc7 100644
--- a/templates/login/form.html
+++ b/templates/login/form.html
@@ -33,7 +33,11 @@
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-md-offset-2 col-xs-12 col-sm-10 col-md-10 submit">
- <a href="{{ basepath }}/" title="Cancel" class="btn btn-link" tabindex="4">Cancel</a>
+ {% if cancel_url %}
+ <a href="{{ cancel_url }}" title="Cancel" class="btn btn-link" tabindex="4">Cancel</a>
+ {% else %}
+ <a href="{{ basepath }}" title="Cancel" class="btn btn-link" tabindex="4">Cancel</a>
+ {% endif %}
{% if next_url %}
<a href="{{ next_url }}" title="Next authentication method" class="btn btn-link" tabindex="5">Next method </a>
{% endif %}