def check_admin_or_owner(resource_owner): if not validate_auth_basics(): raise exc.AuthenticationRequired() context = get_auth_context() if not context['is_admin'] or resource_owner is None: raise exc.AuthenticationRequired() user = db.get_owner(resource_owner) if not context['userid'] == user.id: raise exc.AuthenticationRequired()
def attach_owner(self, owner_id, required=True): user, id = db.get_owner(owner_id) if required and user is None: if id is None: raise f_exc.OwnerRequired() if id is not None: raise exc.NotFound() if user is not None: self.attachments['owner'] = user return user return None
def check_owner(resource_owner): if not validate_auth_basics(): raise exc.AuthenticationRequired() context = get_auth_context() if check_context_for_admin(context): return if resource_owner is None: raise exc.AuthenticationRequired() user, id = db.get_owner(resource_owner) if not context['userid'] == user.id: if not check_context_for_admin(context): raise cexc.NotFound()
def add_owner_filter(self, owner_id): user, id = db.get_owner(owner_id) if user is not None: self.additional_filters['owner_id'] = user.id