From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
let cookie remember the last page.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
---
src/kimchi/root.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/root.py b/src/kimchi/root.py
index 181ab13..651c847 100644
--- a/src/kimchi/root.py
+++ b/src/kimchi/root.py
@@ -93,7 +93,11 @@ def tabs(self, page, **kwargs):
data['ui_dir'] = paths.ui_dir
if page.endswith('.html'):
- return template.render('tabs/' + page, data)
+ context = template.render('tabs/' + page, data)
+ cherrypy.response.cookie[
+ "lastPage"] = "/#tabs/" +
page.rstrip(".html")
+ cherrypy.response.cookie['lastPage']['path'] = '/'
+ return context
raise cherrypy.HTTPError(404)
@@ -115,9 +119,13 @@ def login(self, *args, **kwargs):
password = kwargs.get('password')
# forms base authentication
if username is not None:
- # UI can pass the redirect url by "next" query parameter
- next_url = kwargs.get('next', "/")
- next_url = type(next_url) is list and next_url[0]
+ next_url = cherrypy.request.cookie.get("lastPage")
+ if next_url is None:
+ # UI can pass the redirect url by "next" query parameter
+ next_url = kwargs.get('next', "/")
+ next_url = type(next_url) is list and next_url[0]
+ else:
+ next_url = next_url.value
auth.login(username, password)
raise cherrypy.HTTPRedirect(next_url, 303)
else:
--
1.9.3