Sha256: 10d0377e3e3d3eb5a9575abc233743965d8c5dd898c6f5a33bc7781acf881984

Contents?: true

Size: 1.09 KB

Versions: 38

Compression:

Stored size: 1.09 KB

Contents

module ForestLiana
  class AllowedUsersGetter < UsersGetter
    def initialize(rendering_id)
      super('allowed-users', rendering_id)
    end

    def handle_service_response(response)
      if response.is_a?(Net::HTTPOK)
        body = JSON.parse(response.body)
        ForestLiana.allowed_users = body['data'].map do |d|
          user = d['attributes']
          user['id'] = d['id']

          user
        end
      elsif response.is_a?(Net::HTTPNotFound)
        FOREST_LOGGER.error "Cannot retrieve the project you\'re trying " \
          "to unlock. Can you check that you properly copied the Forest " \
          "env_secret in the forest_liana initializer?"
      elsif response.is_a?(Net::HTTPUnprocessableEntity)
        FOREST_LOGGER.error "Cannot retrieve any users for the project you\'re trying to " \
          "unlock. Your secret key seems to be missing in your Forest configuration."
        []
      else
        FOREST_LOGGER.error "Cannot retrieve any users for the project " \
          "you\'re trying to unlock. An error occured in Forest API."
        []
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
forest_liana-2.11.13 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.12 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.11 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.10 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.9 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.8 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.7 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.6 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.5 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.4 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.3 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.2 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.1 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.11.0 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.10.5 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.10.4 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.10.3 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.10.2 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.10.1 app/services/forest_liana/allowed_users_getter.rb
forest_liana-2.10.0 app/services/forest_liana/allowed_users_getter.rb