omniauth-intercom 0.1.0 → 0.1.1

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: 9db0767314f658f4a3edbbfa8a378877c95f6e26
4
- data.tar.gz: d799638a2712b3ddfcf817479c7477c3f0bfa8ee
3
+ metadata.gz: e4b9a3e6d43aab0e16d421199e711811a99af80b
4
+ data.tar.gz: 851ce2cc70ec3088218d8057952166421e2275dc
5
5
  SHA512:
6
- metadata.gz: 54bba5243a083f4bc7b36a378b736a06192c1289bcceaabd4daba13e2b56112490bcf651ec87eef1626472f7d33ff0bffbbe39db535eda02a14c1be3427ed057
7
- data.tar.gz: 828e403a165adedd6e135d81da5eb554cf11cd94cfaf5c2fec25176bdbf80cc60f21b60353c61fe2c0673a61fadc655309bf6b28eae5a08a370601ac0b4e4a67
6
+ metadata.gz: 291e5181db1f500963bbb928c3bd555a63c1cbf56fd9cd6896a52a16f53d1284a4949e8c746defd9c666669006b6e1022530187314760087cc83f3168c9b03d1
7
+ data.tar.gz: 2c6831280024a72c47d917e79735934450da7707ff5a0e89a729a50482cb2a176868564db7aeb759f8de98ec4791c574f984fe738f35102c94a8d6d7552ffcef
data/CHANGELOG.md CHANGED
@@ -3,3 +3,9 @@
3
3
  Features:
4
4
 
5
5
  - Omniauth2 basic auth (@Skaelv)
6
+
7
+ ## 0.1.0 (2016-05-03)
8
+
9
+ Features:
10
+
11
+ - Add support for signup (@Skaelv)
data/README.md CHANGED
@@ -27,6 +27,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
27
27
  end
28
28
  ```
29
29
  To start the authentication process with Intercom you simply need to access `/auth/intercom` route.
30
+ You can start the authentication process directly with the signup page by accessing `/auth/intercom?signup=1`
30
31
 
31
32
  **Important** You need the `read_admins` permissions to use this middleware.
32
33
  **Important** Your `redirect_url` should be `/auth/intercom/callback`
@@ -64,3 +65,53 @@ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
64
65
  }
65
66
  }
66
67
  ```
68
+
69
+ ### Intercom Button / Popup authentication
70
+
71
+ To use `Intercom Button` to display authentication in a popup it is simple :
72
+
73
+ - Add the following code in the html file in which you want to start to authenticate with Intercom ( `/views/home/index.html.erb` if you want to authenticate with Intercom in `home#index`)
74
+
75
+ ```html
76
+ <a href="javascript:void(0)" class="intercom-oauth-cta">
77
+ <img src="https://static.intercomassets.com/assets/oauth/primary-7edb2ebce84c088063f4b86049747c3a.png" srcset="https://static.intercomassets.com/assets/oauth/primary-7edb2ebce84c088063f4b86049747c3a.png 1x, https://static.intercomassets.com/assets/oauth/primary@2x-0d69ca2141dfdfa0535634610be80994.png 2x, https://static.intercomassets.com/assets/oauth/primary@3x-788ed3c44d63a6aec3927285e920f542.png 3x"/>
78
+ </a>
79
+ <script type="text/javascript">
80
+ $('.intercom-oauth-cta').unbind('click').click(function() {
81
+ var auth_window = window.open('/auth/intercom', 'Sign in', 'width=700,height=450');
82
+ var checkWindow = function() {
83
+ if (auth_window.closed) {
84
+ window.location = '/';
85
+ } else if (window.oauth_success === undefined) {
86
+ setTimeout(checkWindow, 200);
87
+ }
88
+ };
89
+ checkWindow();
90
+ });
91
+ </script>
92
+ ```
93
+
94
+ Create a `views/home/intercom_callback.html.erb` file ( if your callback route is `home#intercom_callback`)
95
+
96
+ ```html
97
+ <html>
98
+ <head>
99
+ <title>Authorized</title>
100
+ </head>
101
+ <body>
102
+ <script type="text/javascript">
103
+ setTimeout(function() {
104
+ if (window.opener) {
105
+ window.opener.oauth_success = true;
106
+ }
107
+ window.close();
108
+ }, 1000);
109
+ </script>
110
+ </body>
111
+ </html>
112
+ ```
113
+
114
+
115
+ ### Example application
116
+
117
+ [testapp-intercom-omniauth](https://github.com/Skaelv/testapp-intercom-omniauth) is a simple application implementing the authentication process with Intercom with a popup display.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Intercom
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -40,7 +40,17 @@ module OmniAuth
40
40
  @raw_info ||= access_token.get('/me').parsed
41
41
  end
42
42
 
43
+ def request_phase
44
+ authorize_url
45
+ super
46
+ end
47
+
43
48
  protected
49
+
50
+ def authorize_url
51
+ options.client_options[:authorize_url] += '/signup' if request.params.fetch('signup', false)
52
+ end
53
+
44
54
  def accept_headers
45
55
  access_token.client.connection.headers['Authorization'] = access_token.client.connection.basic_auth(access_token.token, '')
46
56
  access_token.client.connection.headers['Accept'] = "application/vnd.intercom.3+json"
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.0
4
+ version: 0.1.1
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-05-03 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2