summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Woods <wwoods@redhat.com>2009-09-16 16:48:16 -0400
committerWill Woods <wwoods@redhat.com>2009-09-16 16:48:16 -0400
commitb1ff27840074f1079bcd084094019e70c547761f (patch)
tree87067cf6e31b61d3513458ccc58b47ed235b8c50
parent1b3e54e816335aa0259c88b933622d1d2c8f7a4d (diff)
downloadisrawhidebroken-b1ff27840074f1079bcd084094019e70c547761f.tar.gz
israwhidebroken-b1ff27840074f1079bcd084094019e70c547761f.tar.xz
israwhidebroken-b1ff27840074f1079bcd084094019e70c547761f.zip
Add json support for login/logout as per python-fedora docs
-rw-r--r--israwhidebroken/controllers.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/israwhidebroken/controllers.py b/israwhidebroken/controllers.py
index 4b3062d..0883216 100644
--- a/israwhidebroken/controllers.py
+++ b/israwhidebroken/controllers.py
@@ -1,4 +1,5 @@
import turbogears as tg
+import fedora
from turbogears import controllers, expose, flash
from israwhidebroken.model import Test, Tree, TestResult, hub
from sqlobject import AND
@@ -64,6 +65,7 @@ class Root(controllers.RootController):
# Identity stuff (login/logout)
@expose(template="israwhidebroken.templates.login")
+ @expose(allow_json=True)
def login(self, forward_url=None, *args, **kw):
if forward_url:
@@ -75,6 +77,8 @@ class Root(controllers.RootController):
# If the login was successful...
if not identity.current.anonymous and identity.was_login_attempted() \
and not identity.get_identity_errors():
+ if 'json' == fedora.tg.util.request_format():
+ return dict(user=identity.current.user)
flash("Welcome, %s" % identity.current.user_name)
redirect(tg.url(forward_url or '/', kw))
@@ -94,7 +98,9 @@ class Root(controllers.RootController):
forward_url=forward_url, previous_url=request.path_info,
original_parameters=request.params)
- @expose()
+ @expose(allow_json=True)
def logout(self):
identity.current.logout()
+ if 'json' in fedora.tg.util.request_format():
+ return dict()
redirect("/")