Sha256: f5488a9da77ce959067735a6b53442fcbf0197834df9c420ffdcd9fefdc48e1e

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class Vatsimsso < OmniAuth::Strategies::OAuth2
      option :name, 'vatsimsso'
      option :client_options,
             site: 'https://auth-dev.vatsim.net',
             authorize_url: '/oauth/authorize',
             token_url: '/oauth/token'

      uid do
        raw_info.dig('data', 'cid').to_s
      end

      info do
        {
          name_full: raw_info.dig('data', 'personal', 'name_full'),
          email: raw_info.dig('data', 'personal', 'email'),
          rating: raw_info.dig('data', 'vatsim', 'rating', 'short')
        }
      end

      extra do
        { raw_info: raw_info }
      end

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

      def callback_url
        full_host + script_name + callback_path
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-vatsimsso-0.1.1 lib/omniauth/strategies/vatsimsso.rb