allow the logout method to be called via json.

This commit is contained in:
Toshio Kuratomi 2008-03-03 07:17:50 -08:00
parent 9887f53654
commit 95f1b8f1ba

View file

@ -99,8 +99,14 @@ class Root(controllers.RootController):
original_parameters=request.params,
forward_url=forward_url)
@expose()
@expose(allow_json=True)
def logout(self):
identity.current.logout()
turbogears.flash(_('You have successfully logged out.'))
if 'tg_format' in request.params \
and request.params['tg_format'] == 'json':
# When called as a json method, doesn't make any sense to
# redirect to a page. Returning the logged in identity
# is better.
return dict(status=True)
raise redirect(request.headers.get("Referer", "/"))