From 26babd7e96a2784daeddbfbd5bfd61579cf3487a Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sat, 6 Apr 2013 09:52:42 -0500 Subject: [PATCH] fixed Issue 1416:auth.wiki login loop unless the user is admin, thanks Alan --- VERSION | 2 +- gluon/fileutils.py | 7 +++++-- gluon/tools.py | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 3734e654..5b1da27a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.5-stable+timestamp.2013.04.06.09.48.12 +Version 2.4.5-stable+timestamp.2013.04.06.09.52.04 diff --git a/gluon/fileutils.py b/gluon/fileutils.py index 293f3e08..0f3953bb 100644 --- a/gluon/fileutils.py +++ b/gluon/fileutils.py @@ -367,16 +367,19 @@ def get_session(request, other_application='admin'): return osession -def check_credentials(request, other_application='admin', expiration=60 * 60): +def check_credentials(request, other_application='admin', + expiration=60 * 60, gae_login=True): """ checks that user is authorized to access other_application""" if request.env.web2py_runtime_gae: from google.appengine.api import users if users.is_current_user_admin(): return True - else: + elif gae_login: login_html = 'Sign in with your google account.' \ % users.create_login_url(request.env.path_info) raise HTTP(200, '%s' % login_html) + else: + return False else: dt = time.time() - expiration s = get_session(request, other_application) diff --git a/gluon/tools.py b/gluon/tools.py index e2be49e7..6b981090 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -5073,8 +5073,10 @@ class Wiki(object): db.wiki_tag.insert(name=tag, wiki_page=page.id) db.wiki_page._after_insert.append(update_tags_insert) db.wiki_page._after_update.append(update_tags_update) - if auth.user and check_credentials(current.request) and \ - not 'wiki_editor' in auth.user_groups.values(): + + if (auth.user and + check_credentials(current.request, gae_login=False) and + not 'wiki_editor' in auth.user_groups.values()): group = db.auth_group(role='wiki_editor') gid = group.id if group else db.auth_group.insert( role='wiki_editor')