class OmniAuth::Strategies::Wonde

Authentication strategy for Wonde

Wonde implements OAuth 2 (three legged)

Constants

USER_INFO_URL

Public Class Methods

user_query_body() click to toggle source

@return [String] JSON string

# File lib/omniauth/strategies/wonde.rb, line 44
def self.user_query_body
  @user_query_body ||= begin
    gql = File.read(File.expand_path("user_data.graphql", __dir__))
    { query: gql }.to_json
  end
end

Public Instance Methods

callback_url() click to toggle source

@return [String]

# File lib/omniauth/strategies/wonde.rb, line 60
def callback_url
  options[:redirect_uri] ||
    (
      full_host +
      script_name +
      callback_path
    )
  # "#{full_host}#{script_name}#{callback_path}"
end
raw_info() click to toggle source

@return [Hash]

# File lib/omniauth/strategies/wonde.rb, line 52
def raw_info
  @raw_info ||= begin
    data = fetch_user_info.parsed || {}
    data["data"] || {}
  end
end

Private Instance Methods

fetch_user_info() click to toggle source

Retrieve basic user info

POST to Wonde GraphQL API

# File lib/omniauth/strategies/wonde.rb, line 75
def fetch_user_info
  access_token.post(USER_INFO_URL) do |req|
    req.headers['Content-Type'] = "application/json"
    req.body = self.class.user_query_body
  end
end
prune!(hash) click to toggle source

Remove empty values from hash

@param hash [Hash] @return [Hash]

# File lib/omniauth/strategies/wonde.rb, line 86
def prune!(hash)
  hash.delete_if do |_, v|
    prune!(v) if v.is_a?(Hash)
    v.nil? || (v.respond_to?(:empty?) && v.empty?)
  end
end