Sha256: 10bce1ac50f989fd632bbd57125a0601f7c77085448e5b949a6db1564258705b

Contents?: true

Size: 993 Bytes

Versions: 2

Compression:

Stored size: 993 Bytes

Contents

module ForestLiana
  class TwoFactorRegistrationConfirmer
    def initialize(
      project_id,
      use_google_authentication,
      auth_data
    )
      @project_id = project_id
      @use_google_authentication = use_google_authentication
      @auth_data = auth_data
    end

    def perform
      begin
        body_data = { 'useGoogleAuthentication' => @use_google_authentication }

        if @use_google_authentication
          body_data['forestToken'] = @auth_data[:forest_token]
        else
          body_data['email'] = @auth_data[:email]
        end

        response = ForestApiRequester.post(
          "/liana/v2/projects/#{@project_id}/two-factor-registration-confirm",
          body: body_data,
        )

        unless response.is_a?(Net::HTTPOK)
          raise "Cannot retrieve the data from the Forest server. Forest API returned an #{Errors::HTTPErrorHelper.format(response)}"
        end
      rescue
        raise Errors::HTTP401Error
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
forest_liana-2.13.0 app/services/forest_liana/two_factor_registration_confirmer.rb
forest_liana-2.12.0 app/services/forest_liana/two_factor_registration_confirmer.rb