Make checkAgreesToSiteToS() the default access check for many other checks.
authorTodd Larsen <tlarsen@google.com>
Wed, 21 Jan 2009 21:32:51 +0000
changeset 889 5f3136a5eb4c
parent 888 a75ae24f04cb
child 890 b3bf833c4580
Make checkAgreesToSiteToS() the default access check for many other checks. Replace checkIsUser() with the more-strict checkAgreesToSiteToS(). Also, add missing args and kwargs parameters to checkAgreesToSiteToS() that were missed in the merge right before commit. Patch by: Todd Larsen Review by: to-be-reviewed
app/soc/views/helper/access.py
--- a/app/soc/views/helper/access.py	Wed Jan 21 21:25:18 2009 +0000
+++ b/app/soc/views/helper/access.py	Wed Jan 21 21:32:51 2009 +0000
@@ -183,7 +183,7 @@
   raise out_of_band.LoginRequest(message_fmt=DEF_NO_USER_LOGIN_MSG_FMT)
 
 
-def checkAgreesToSiteToS(request):
+def checkAgreesToSiteToS(request, args, kwargs):
   """Raises an alternate HTTP response if User has not agreed to site-wide ToS.
 
   Args:
@@ -195,7 +195,7 @@
     * if no User exists for the logged-in Google Account, or
     * if no Google Account is logged in at all
   """
-  checkIsUser(request)
+  checkIsUser(request, args, kwargs)
 
   user = user_logic.getForFields({'account': users.get_current_user()},
                                  unique=True)
@@ -223,6 +223,7 @@
     * if no User exists for the logged-in Google Account, or
     * if no Google Account is logged in at all
   """
+  # Developers need to bypass the ToS check to avoid "chicken-and-egg" problem
   checkIsUser(request, args, kwargs)
 
   if accounts.isDeveloper(account=users.get_current_user()):
@@ -257,7 +258,7 @@
   except out_of_band.Error:
     pass
 
-  checkIsUser(request, args, kwargs)
+  checkAgreesToSiteToS(request, args, kwargs)
 
   user = user_logic.getForFields({'account': users.get_current_user()},
                                  unique=True)
@@ -296,7 +297,7 @@
   except out_of_band.Error:
     pass
 
-  checkIsUser(request, args, kwargs)
+  checkAgreesToSiteToS(request, args, kwargs)
 
   # TODO(srabbelier) implement this
 
@@ -329,7 +330,7 @@
   except out_of_band.Error:
     pass
 
-  checkIsUser(request, args, kwargs)
+  checkAgreesToSiteToS(request, args, kwargs)
 
   login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % {
       'role': 'a Program Administrator for this Program'}
@@ -391,7 +392,7 @@
     except out_of_band.Error:
       pass
 
-    checkIsUser(request, args, kwargs)
+    checkAgreesToSiteToS(request, args, kwargs)
 
     user = user_logic.getForCurrentAccount()
 
@@ -434,7 +435,7 @@
   except out_of_band.Error:
     pass
 
-  checkIsUser(request, args, kwargs)
+  checkAgreesToSiteToS(request, args, kwargs)
 
   # Mine the url for params
   try:
@@ -479,7 +480,7 @@
     except out_of_band.Error:
       pass
 
-    checkIsUser(request, args, kwargs)
+    checkAgreesToSiteToS(request, args, kwargs)
 
     properties = dicts.filter(kwargs, ['link_id'])