class Openid

Public Class Methods

new(verify_url, state) click to toggle source
# File lib/openid/openid.rb, line 6
def initialize verify_url, state
  @verify_url = verify_url
  @key = state.keys.first
  @name = state.values.first[:name].to_sym
end

Public Instance Methods

auth_request(step = :step1) click to toggle source
# File lib/openid/openid.rb, line 12
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
error_response(error_message) click to toggle source
# File lib/openid/openid.rb, line 39
def error_response error_message
  {
      state: :shit,
      error: error_message
  }
end
oauth_access_card_params(id) click to toggle source
# File lib/openid/openid.rb, line 21
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