Beispiel #1
0
 def wrapped(*args, access_token=None, course="cs61a", **kwargs):
     token_good = access_token and is_admin_token(access_token=access_token,
                                                  course=course)
     cookie_good = is_staff(course=course) and is_admin(
         email=get_user()["email"], course=course)
     if token_good or cookie_good:
         try:
             return func(*args, **kwargs, course=course)
         except PermissionError:
             pass
     if access_token:
         raise PermissionError
     else:
         return login()
Beispiel #2
0
 def wrapped(
     *,
     master_secret=None,
     _sudo_token=None,
     _impersonate=None,
     _is_staging=False,
     **kwargs,
 ):
     if master_secret:
         app, is_staging = validate_master_secret(master_secret=master_secret)
         return func(app=app, is_staging=is_staging, **kwargs)
     elif _sudo_token and is_admin_token(_sudo_token, course="cs61a"):
         return func(app=_impersonate, is_staging=_is_staging, **kwargs)
     raise PermissionError