Sha256: 33d87240c283660833be7410179a0e9483c94787f2c92c7afa650e31e4bd2f1c

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

require 'omniauth/oauth'
require 'multi_json'

module OmniAuth
  module Strategies
    class ThirtySevenSignals < OAuth2
      def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
        client_options = {
          :site => 'https://launchpad.37signals.com/',
          :authorize_path => '/authorization/new',
          :access_token_path => '/authorization/token'
        } 
        
        super(app, :thirty_seven_signals, client_id, client_secret, client_options, options, &block)
      end
      
      def user_data
        @data ||= MultiJson.decode(@access_token.get('/authorization.json'))
      end
      
      def user_info
        {
          'email' => user_data['identity']['email_address'],
          'first_name' => user_data['identity']['first_name'],
          'last_name' => user_data['identity']['last_name'],
          'name' => [user_data['identity']['first_name'], user_data['identity']['last_name']].join(' ').strip
        }
      end
      
      def auth_hash
        OmniAuth::Utils.deep_merge(super, {
          'uid' => user_data['identity']['id'],
          'user_info' => user_info,
          'extra' => {
            'accounts' => user_data['accounts']
          }
        })
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
oa-oauth-0.2.4 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.3 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.2 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.1 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.0 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.0.beta5 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.0.beta4 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.0.beta3 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.0.beta2 lib/omniauth/strategies/thirty_seven_signals.rb
oa-oauth-0.2.0.beta1 lib/omniauth/strategies/thirty_seven_signals.rb