fixed Issue 1416:auth.wiki login loop unless the user is admin, thanks Alan
This commit is contained in:
@@ -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
|
||||||
|
|||||||
+5
-2
@@ -367,16 +367,19 @@ def get_session(request, other_application='admin'):
|
|||||||
return osession
|
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"""
|
""" checks that user is authorized to access other_application"""
|
||||||
if request.env.web2py_runtime_gae:
|
if request.env.web2py_runtime_gae:
|
||||||
from google.appengine.api import users
|
from google.appengine.api import users
|
||||||
if users.is_current_user_admin():
|
if users.is_current_user_admin():
|
||||||
return True
|
return True
|
||||||
else:
|
elif gae_login:
|
||||||
login_html = '<a href="%s">Sign in with your google account</a>.' \
|
login_html = '<a href="%s">Sign in with your google account</a>.' \
|
||||||
% users.create_login_url(request.env.path_info)
|
% users.create_login_url(request.env.path_info)
|
||||||
raise HTTP(200, '<html><body>%s</body></html>' % login_html)
|
raise HTTP(200, '<html><body>%s</body></html>' % login_html)
|
||||||
|
else:
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
dt = time.time() - expiration
|
dt = time.time() - expiration
|
||||||
s = get_session(request, other_application)
|
s = get_session(request, other_application)
|
||||||
|
|||||||
+4
-2
@@ -5073,8 +5073,10 @@ class Wiki(object):
|
|||||||
db.wiki_tag.insert(name=tag, wiki_page=page.id)
|
db.wiki_tag.insert(name=tag, wiki_page=page.id)
|
||||||
db.wiki_page._after_insert.append(update_tags_insert)
|
db.wiki_page._after_insert.append(update_tags_insert)
|
||||||
db.wiki_page._after_update.append(update_tags_update)
|
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')
|
group = db.auth_group(role='wiki_editor')
|
||||||
gid = group.id if group else db.auth_group.insert(
|
gid = group.id if group else db.auth_group.insert(
|
||||||
role='wiki_editor')
|
role='wiki_editor')
|
||||||
|
|||||||
Reference in New Issue
Block a user