From 37acdc0cc66eec4c65fcf59b1136c2e3fda83d4b Mon Sep 17 00:00:00 2001 From: mdipierro Date: Wed, 12 Dec 2012 22:07:20 -0600 Subject: [PATCH] partially fixed issue 832, auth.requires raises 401 on ajax, thanks Paolo Valleri --- VERSION | 2 +- gluon/tools.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index c2738e24..910de432 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.3.0 (2012-12-12 22:02:50) rc1 +Version 2.3.0 (2012-12-12 22:06:35) rc1 diff --git a/gluon/tools.py b/gluon/tools.py index 325ff533..f1c4a798 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -2899,7 +2899,9 @@ class Auth(object): user = user or self.user if requires_login: if not user: - if not otherwise is None: + if current.request.ajax: + raise HTTP(401) + elif not otherwise is None: if callable(otherwise): return otherwise() redirect(otherwise)