Ejemplo n.º 1
0
    def check_manageable(self, trans, folder):
        """
        Check whether the user can manage the folder.

        :returns:   the original folder
        :rtype:     LibraryFolder

        :raises: AuthenticationRequired, InsufficientPermissionsException
        """
        if not trans.user:
            raise AuthenticationRequired("Must be logged in to manage Galaxy items.", type='error')
        current_user_roles = trans.get_current_user_roles()
        if not trans.app.security_agent.can_manage_library_item(current_user_roles, folder):
            raise InsufficientPermissionsException("You don't have permissions to manage this folder.", type='error')
        else:
            return folder
Ejemplo n.º 2
0
 def check_user_is_authenticated(self, trans: ProvidesUserContext):
     """Raises an exception if the request is anonymous."""
     if trans.anonymous:
         raise AuthenticationRequired(
             "API authentication required for this request")