omniauth-intercom 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfacd27e923da6ff12e6fa19596a8da33b0b536c
4
- data.tar.gz: d5d22d9023725fb0c148b3626eac0de441fe1a0b
3
+ metadata.gz: 9bf15af1eeacf96af125225fe34ee4d9542c3903
4
+ data.tar.gz: 32add95875eaf5a13d0bddcb9380699b6e515eae
5
5
  SHA512:
6
- metadata.gz: 0585d860eb475bf66ce0099de68143d8d60e9a94098992a6d4ca645937b2029828f9c4c24435cc51d13e232d79f18071c3c80f73a30e8b9321611e7ceab0c24d
7
- data.tar.gz: 300f09777d0919b3a88cf1994dbc02886a37f2d11695a1ecce568b4f2dca54aaeba665c458f5f6742c524dd223af78e499320577cf1c854b1a4e5bdd242ad6a7
6
+ metadata.gz: f064f379bb6246a1bdb1bbd0130a43c3f2725e8f528befc4c38f5cbadf06f423c2f6b341afdc4b77159980d3081d0525f5b494e1d2f2b88830cd7e8790910a85
7
+ data.tar.gz: 5c71830b5e42722f239a7956fa4c560970f5b55b2772aaee89f87f5f20a1984fee39e0fd6cd66f938946b95a33ce105158f49a83d14e8f34d6b76a6056d0ca57
@@ -10,8 +10,14 @@ Features:
10
10
 
11
11
  - Add support for signup (@Skaelv)
12
12
 
13
- ## 0.1.2 (2016-06-14)
13
+ ## 0.1.2 (2016-06-14)
14
14
 
15
- Features:
15
+ Features:
16
+
17
+ - add support for avatar (thanks @bnorton)
18
+
19
+ ## 0.1.3 (2016-07-26)
20
+
21
+ Features:
16
22
 
17
- - add support for avatar (thanks @bnorton)
23
+ - allow to pre-populate oauth signup form fields (name, email, app_name) (@Skaelv)
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Intercom
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -1,4 +1,6 @@
1
1
  require 'omniauth-oauth2'
2
+ require 'uri'
3
+
2
4
  module OmniAuth
3
5
  module Strategies
4
6
  class Intercom < OmniAuth::Strategies::OAuth2
@@ -36,8 +38,7 @@ module OmniAuth
36
38
  end
37
39
 
38
40
  def request_phase
39
- options.client_options[:authorize_url] += '/signup' if request.params.fetch('signup', false)
40
-
41
+ prepopulate_signup_fields_form if request.params.fetch('signup', false)
41
42
  super
42
43
  end
43
44
 
@@ -48,6 +49,20 @@ module OmniAuth
48
49
  access_token.client.connection.headers['Accept'] = "application/vnd.intercom.3+json"
49
50
  end
50
51
 
52
+ def prepopulate_signup_fields_form
53
+ options.client_options[:authorize_url] += '/signup'
54
+ signup_hash = signup_fields_hash
55
+ options.client_options[:authorize_url] += '?' + signup_hash.map{|k,v| [CGI.escape(k.to_s), "=", CGI.escape(v.to_s)]}.map(&:join).join("&") unless signup_hash.empty?
56
+ end
57
+
58
+ def signup_fields_hash
59
+ hash = {}
60
+ ['name', 'email', 'app_name'].each do |field_name|
61
+ hash[field_name] = request.params.fetch(field_name) if request.params.fetch(field_name, false)
62
+ end
63
+ return hash
64
+ end
65
+
51
66
  end
52
67
  end
53
68
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.12"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "rack", "~> 1.6"
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-intercom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Antoine
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-14 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
69
83
  description:
70
84
  email:
71
85
  - kevin.antoine@intercom.io
@@ -108,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
122
  version: '0'
109
123
  requirements: []
110
124
  rubyforge_project:
111
- rubygems_version: 2.4.8
125
+ rubygems_version: 2.6.1
112
126
  signing_key:
113
127
  specification_version: 4
114
128
  summary: Intercom OAuth2 Strategy for OmniAuth