app/models/project.rb
# validate that the user is a member of the registered project
validate that the user is a member of the registered project
validate that the user is a member of the registered project
def verify_project_membership
    if self.namespace.blank?
      false 
    else
      client = FireCloudClient.new(self.user, self.namespace)
      begin
        projects = client.get_billing_projects
        fc_project = projects.detect {|acl| acl['projectName'] == self.namespace}
        if fc_project.present?
          self.user_role = fc_project['role']
          Rails.logger.info "setting user role: #{self.user_role} from #{fc_project['role']}"
          true
        else
          Rails.logger.error "#{self.user.email} is not a member of project #{self.namespace}"
          errors.add(:namespace, " - You must be a member of '#{self.namespace}' to use it with Unity.  Please select another project.")
        end
      rescue => e
        Rails.logger.error "Unable to verify project membership of #{self.namespace} for #{self.user.email}: #{e.message}"
        errors.add(:namespace, " - We are unable to verify project permissions for #{self.namespace} due to an error.  Please select another project.")
      end
    end
  end
def verify_project_membership if self . namespace . blank? false else client = FireCloudClient . new ( self . user , self . namespace ) begin projects = client . get_billing_projects fc_project = projects . detect { | acl | acl [ 'projectName' ] == self . namespace } if fc_project . present? self . user_role = fc_project [ 'role' ] Rails . logger . info "setting user role: #{self.user_role} from #{fc_project['role']}" true else Rails . logger . error "#{self.user.email} is not a member of project #{self.namespace}" errors . add ( :namespace , " - You must be a member of '#{self.namespace}' to use it with Unity.  Please select another project." ) end rescue => e Rails . logger . error "Unable to verify project membership of #{self.namespace} for #{self.user.email}: #{e.message}" errors . add ( :namespace , " - We are unable to verify project permissions for #{self.namespace} due to an error.  Please select another project." ) end end end
validate that the user is a member of the registered project
validate that the user is a member of the registered project
# just return false as the namespace validation will catch this and set the proper error # set the project user role