From f94bc250eb363bd168e7d65a1f0980b03bfb3859 Mon Sep 17 00:00:00 2001 From: dsk7 Date: Sun, 2 Aug 2015 13:21:20 +0200 Subject: [PATCH] Allow to specify a function for requires_login at auth decoration. --- gluon/tools.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gluon/tools.py b/gluon/tools.py index 95f803d1..1d96905f 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -3739,7 +3739,12 @@ class Auth(object): basic_allowed, basic_accepted, user = self.basic() user = user or self.user - if requires_login: + + login_required = requires_login + if callable(login_required): + login_required = login_required() + + if login_required: if not user: if current.request.ajax: raise HTTP(401, self.messages.ajax_failed_authentication)