omniauth-salesforce 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Salesforce
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -3,12 +3,29 @@ require 'omniauth-oauth2'
3
3
  module OmniAuth
4
4
  module Strategies
5
5
  class Salesforce < OmniAuth::Strategies::OAuth2
6
+
7
+ MOBILE_USER_AGENTS = 'webos|ipod|iphone|mobile'
8
+
6
9
  option :client_options, {
7
10
  :site => 'https://login.salesforce.com',
8
11
  :authorize_url => '/services/oauth2/authorize',
9
12
  :token_url => '/services/oauth2/token'
10
13
  }
14
+ option :authorize_options, [
15
+ :scope,
16
+ :display,
17
+ :immediate,
18
+ :state
19
+ ]
20
+
11
21
  def request_phase
22
+ req = Rack::Request.new(@env)
23
+ options.update(req.params)
24
+ ua = req.user_agent.to_s
25
+ if !options.has_key?(:display)
26
+ mobile_request = ua.downcase =~ Regexp.new(MOBILE_USER_AGENTS)
27
+ options[:display] = mobile_request ? 'touch' : 'page'
28
+ end
12
29
  super
13
30
  end
14
31
 
@@ -23,15 +40,9 @@ module OmniAuth
23
40
  'last_name' => raw_info['last_name'],
24
41
  'location' => '',
25
42
  'description' => '',
26
- 'image' => raw_info['nick_name'],
43
+ 'image' => raw_info['photos']['thumbnail'] + "?oauth_token=#{access_token.token}",
27
44
  'phone' => '',
28
- 'urls' => raw_info['urls'],
29
- 'organizationid' => raw_info['organization_id'],
30
- 'userid' => raw_info['user_id'],
31
- 'username' => raw_info['username'],
32
- 'organization_id' => raw_info['organization_id'],
33
- 'user_id' => raw_info['user_id'],
34
- 'user_name' => raw_info['username']
45
+ 'urls' => raw_info['urls']
35
46
  }
36
47
  end
37
48
 
@@ -40,6 +51,22 @@ module OmniAuth
40
51
  access_token.options[:param_name] = :oauth_token
41
52
  @raw_info ||= access_token.post(access_token['id']).parsed
42
53
  end
54
+
55
+ extra do
56
+ raw_info.merge({
57
+ 'instance_url' => access_token.params['instance_url'],
58
+ 'pod' => access_token.params['instance_url']
59
+ })
60
+ end
61
+
43
62
  end
63
+
64
+ class SalesforceSandbox < OmniAuth::Strategies::Salesforce
65
+ default_options[:client_options][:site] = 'https://test.salesforce.com'
66
+ end
67
+ class DatabaseDotCom < OmniAuth::Strategies::Salesforce
68
+ default_options[:client_options][:site] = 'https://login.database.com'
69
+ end
70
+
44
71
  end
45
- end
72
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-salesforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-08 00:00:00.000000000 Z
12
+ date: 2011-12-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
16
- requirement: &2152205600 !ruby/object:Gem::Requirement
16
+ requirement: &2164515840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152205600
24
+ version_requirements: *2164515840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: omniauth-oauth2
27
- requirement: &2152205080 !ruby/object:Gem::Requirement
27
+ requirement: &2164513340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152205080
35
+ version_requirements: *2164513340
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2152204500 !ruby/object:Gem::Requirement
38
+ requirement: &2164512840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.7'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2152204500
46
+ version_requirements: *2164512840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack-test
49
- requirement: &2152204100 !ruby/object:Gem::Requirement
49
+ requirement: &2164504460 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152204100
57
+ version_requirements: *2164504460
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &2152203620 !ruby/object:Gem::Requirement
60
+ requirement: &2164503920 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2152203620
68
+ version_requirements: *2164503920
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &2152203120 !ruby/object:Gem::Requirement
71
+ requirement: &2164503360 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152203120
79
+ version_requirements: *2164503360
80
80
  description: OmniAuth strategy for salesforce.com.
81
81
  email:
82
82
  - rvanhook@salesforce.com