def VerifyPermissions(required_permission, user, permission_type):
  """Verifies a valid user is logged in.

  Args:
    required_permission: permission string from permissions.*.
    user: models.User entity; default current user.
    permission_type: string, one of permission.TYPE_* variables.
  Raises:
    models.AccessDeniedError: there was a permissions issue.
  """
  if not permission_type:
    raise models.AccessDeniedError('permission_type not specified')

  try:
    if not user.HasPerm(required_permission, permission_type=permission_type):
      raise models.AccessDeniedError(
          'User lacks %s permission' % required_permission)
  except __HOLE__:
    raise models.AccessDeniedError(
        'unknown permission_type: %s' % permission_type)
dataset/ETHPy150Open google/cauliflowervest/src/cauliflowervest/server/handlers/__init__.py/VerifyPermissions