From 1014d3e86e7a3b76ae7228a25f8ad2e921411ac3 Mon Sep 17 00:00:00 2001 From: Jose de Soto Date: Mon, 31 Jul 2017 18:33:15 +0200 Subject: [PATCH] new parameter to auto create or not users with alternate login methods --- gluon/tools.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gluon/tools.py b/gluon/tools.py index 1f54e746..4b34be77 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -1792,6 +1792,7 @@ class Auth(AuthAPI): servicevalidate='serviceValidate', proxyvalidate='proxyValidate', logout='logout'), + cas_create_user=True, extra_fields={}, actions_disabled=[], controller=controller, @@ -2284,6 +2285,7 @@ class Auth(AuthAPI): If the user doesn't yet exist, then they are created. """ table_user = self.table_user() + create_user = self.settings.cas_create_user user = None checks = [] # make a guess about who this user is @@ -2316,6 +2318,11 @@ class Auth(AuthAPI): update_keys[key] = keys[key] user.update_record(**update_keys) elif checks: + if create_user is False: + # Remove current open session a send message + self.logout(next=None, onlogout=None, log=None) + raise HTTP(403, "Forbidden. User need to be created first.") + if 'first_name' not in keys and 'first_name' in table_user.fields: guess = keys.get('email', 'anonymous').split('@')[0] keys['first_name'] = keys.get('username', guess)