Sha256: 959d246ae8c78e6622501d17550d9832723ec703ded6b252bc941a455213b5b9

Contents?: true

Size: 960 Bytes

Versions: 5

Compression:

Stored size: 960 Bytes

Contents

class Openid

  require 'uri'
  require 'net/http'

  def initialize verify_url, state
    @verify_url = verify_url
    @key = state.keys.first
    @name = state.values.first[:name].to_sym
  end

  def auth_request step = :step1

    uri = URI CONFIG[:oauth][@name][:auth][step][:uri]
    params = CONFIG[:oauth][@name][:auth][:united_params].merge(CONFIG[:oauth][@name][:auth][step].except(:uri)).merge({'openid.return_to' => @verify_url, 'openid.state' => @key})
    uri.query = URI.encode_www_form params
    uri.to_s

  end

  def oauth_access_card_params id
    begin
      {
        state: :ok,
        oauth_name: @name,
        oauth_uid: id,
        access_token: nil,
        token_expired: nil,
        photourl: nil
      }
    rescue Exception => error
      {
          state: :shit,
          error: error.message
      }
    end
  end

  def error_response error_message
    {
        state: :shit,
        error: error_message
    }
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
digital_heroes_startkit-0.1.1.4 lib/openid/openid.rb
digital_heroes_startkit-0.1.1.3 lib/openid/openid.rb
digital_heroes_startkit-0.1.1.2 lib/openid/openid.rb
digital_heroes_startkit-0.1.1.1 lib/openid/openid.rb
digital_heroes_startkit-0.1.1 lib/openid/openid.rb