Sha256: feb6583dfaeb71e45f019fdce71041845a13bfb4bc60a8866ce1c0af64ff187d

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'omniauth/strategies/oauth2'

module OmniAuth
  module Strategies
    class EauthOauth2 < OmniAuth::Strategies::OAuth2
      option :client_options, {
        :site => 'https://eauth.pelith.com/',
        :authorize_url => '/oauth/authorize',
        :token_url => '/oauth/token'
      }

      def request_phase
        super
      end

      def authorize_params
        super.tap do |params|
          %w[scope client_options].each do |v|
            if request.params[v]
              params[v.to_sym] = request.params[v]
            end
          end
        end
      end

      uid { raw_info['id'].to_s }

      info do
        {
          address: raw_info['address'],
          ens: raw_info['ens']
        }
      end

      extra do
        { raw_info: raw_info }
      end

      def raw_info
        @raw_info ||= access_token.get('/oauth/user').parsed
      end

      private

      def callback_url
        full_host + script_name + callback_path
      end
    end
  end
end

OmniAuth.config.add_camelization 'eauthoauth2', 'EauthOauth2'

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
omniauth-eauth-oauth2-1.0.1.ens lib/omniauth/strategies/eauth_oauth2.rb
omniauth-eauth-oauth2-ens-1.0.2 lib/omniauth/strategies/eauth_oauth2.rb
omniauth-eauth-oauth2-ens-0.0.1 lib/omniauth/strategies/eauth_oauth2.rb