Sha256: 5b0aa12c30539101afa1687557b089e064b4e28e59f05e0bc854bb7d8aa823bb

Contents?: true

Size: 850 Bytes

Versions: 5

Compression:

Stored size: 850 Bytes

Contents

require "omniauth-oauth2"
require "applicaster/accounts"

module OmniAuth
  module Strategies
    class Applicaster < OmniAuth::Strategies::OAuth2
      option :name, :applicaster

      uid { raw_info["id"] }

      info do
        {
          name: raw_info["name"],
          email: raw_info["email"],
          admin: raw_info["admin"],
          account_id: raw_info["account_id"],
          global_roles: raw_info["global_roles"],
          permissions: raw_info["permissions"],
        }
      end

      def raw_info
        @raw_info ||= access_token.get('/api/v1/users/current.json').parsed
      end

      def client
        ::OAuth2::Client.new(
          options.client_id,
          options.client_secret,
          site: ::Applicaster::Accounts.site,
          authorize_url: "/oauth/authorize",
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
omniauth-applicaster-1.1.1 lib/omniauth/strategies/applicaster.rb
omniauth-applicaster-1.1.0 lib/omniauth/strategies/applicaster.rb
omniauth-applicaster-1.0.2 lib/omniauth/strategies/applicaster.rb
omniauth-applicaster-1.0.1 lib/omniauth/strategies/applicaster.rb
omniauth-applicaster-1.0.0 lib/omniauth/strategies/applicaster.rb