Commit bbfaca30 authored by Daniele Venzano's avatar Daniele Venzano

Use reverse_url() in python code

parent 5e0ee603
...@@ -24,7 +24,7 @@ class RootWeb(ZoeWebRequestHandler): ...@@ -24,7 +24,7 @@ class RootWeb(ZoeWebRequestHandler):
def get(self): def get(self):
"""Home page without authentication.""" """Home page without authentication."""
self.redirect("/user") self.redirect(self.reverse_url("/user"))
class LoginWeb(ZoeWebRequestHandler): class LoginWeb(ZoeWebRequestHandler):
...@@ -40,13 +40,13 @@ class LoginWeb(ZoeWebRequestHandler): ...@@ -40,13 +40,13 @@ class LoginWeb(ZoeWebRequestHandler):
password = self.get_argument("password", "") password = self.get_argument("password", "")
user = BaseAuthenticator().full_auth(username, password) user = BaseAuthenticator().full_auth(username, password)
if user is None: if user is None:
self.redirect(self.get_argument("next", u"/login")) self.redirect(self.get_argument("next", self.reverse_url("login")))
return return
if not self.get_secure_cookie('zoe'): if not self.get_secure_cookie('zoe'):
cookie_val = user.username cookie_val = user.username
self.set_secure_cookie('zoe', cookie_val) self.set_secure_cookie('zoe', cookie_val)
self.redirect(self.get_argument("next", u"/user")) self.redirect(self.get_argument("next", self.reverse_url("user")))
class LogoutWeb(ZoeWebRequestHandler): class LogoutWeb(ZoeWebRequestHandler):
...@@ -55,7 +55,7 @@ class LogoutWeb(ZoeWebRequestHandler): ...@@ -55,7 +55,7 @@ class LogoutWeb(ZoeWebRequestHandler):
def get(self): def get(self):
"""Login page.""" """Login page."""
self.clear_cookie('zoe') self.clear_cookie('zoe')
self.redirect(self.get_argument("next", u"/login")) self.redirect(self.get_argument("next", self.reverse_url("login")))
class HomeWeb(ZoeWebRequestHandler): class HomeWeb(ZoeWebRequestHandler):
......
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