omniauth-github-organization 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
  SHA256:
3
- metadata.gz: 0de1670bdccb65312021de8fa605c7b1f916927d461e254bedcf78e6705809c7
4
- data.tar.gz: 52d3f97602da9b052a931efbf83ce0bdf61b78fd6e3ae0f86274ea6503693c44
3
+ metadata.gz: 811e39bdf5700e014003066910ba4001ddc406022ab790dbaae64fc11f397e63
4
+ data.tar.gz: e85af1b4235f3ea36f4d0abff772b14110c64cf06f5c13b434fa7a6f872a78b4
5
5
  SHA512:
6
- metadata.gz: 14bc8f4374cf6646f01de5c0aabbc57591ad727c9cc0b8c6a0428ba565a4518ee16889f2e21e7503f48786a588290c0659f8216cc0bfab1f5a2084aa649968ca
7
- data.tar.gz: 131fae3accfb3fe29ef2fb1eed03aa51f605e0787b900301f9fb37477345b26c260a5eb505594c7dfd6a1d13a6f8cfbf5398ed993aa9f647d635cdb54615454b
6
+ metadata.gz: a71d07929ec95de6600df0357a5bf6a2a47d9aecdc3ff14960ef5ce5ba4a7cad3d293fe8c5c4c7cee63fc042ad969193b5840f2211365009bef24f9926e6af83
7
+ data.tar.gz: 674b7fb11efed63f852fc2e08110c53717f6ef5a2943bfd5432f304c98221fcac8149aaed7a58613ec36abc0e9b4cc5894d72ed2207563690679d5521498eee1
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module GitHubOrganization
3
- VERSION = '0.1.2'.freeze
3
+ VERSION = '0.1.3'.freeze
4
4
  end
5
5
  end
@@ -28,25 +28,14 @@ module OmniAuth
28
28
  end
29
29
 
30
30
  def callback_phase
31
- error = request.params["error_reason"] || request.params["error"]
32
- if error
33
- fail!(error, CallbackError.new(request.params["error"], request.params["error_description"] || request.params["error_reason"], request.params["error_uri"]))
34
- elsif !options.provider_ignores_state && (request.params["state"].to_s.empty? || request.params["state"] != session.delete("omniauth.state"))
35
- fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
36
- else
37
- self.access_token = build_access_token
38
- self.access_token = access_token.refresh! if access_token.expired?
39
- self.access_token.options[:mode] = :query
40
- organizations = self.access_token.get('user/orgs', headers: { 'Accept' => 'application/vnd.github.v3' }).parsed
41
- fail!(:user_denied, CallbackError.new(:user_denied, options['organization'])) unless organizations.map { |x| x['login'] }.include? options['organization']
42
- super
43
- end
44
- rescue ::OAuth2::Error, CallbackError => e
45
- fail!(:invalid_credentials, e)
46
- rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
47
- fail!(:timeout, e)
48
- rescue ::SocketError => e
49
- fail!(:failed_to_connect, e)
31
+ super
32
+ raise(CallbackError.new(:user_denied, options['organization'])) unless organizations.include? options['organization']
33
+ end
34
+
35
+ def organizations
36
+ access_token.options[:mode] = :query
37
+ organizations = access_token.get('user/orgs', headers: { 'Accept' => 'application/vnd.github.v3' }).parsed
38
+ organizations.map { |x| x['login'] }
50
39
  end
51
40
 
52
41
  uid { raw_info['id'].to_s }
@@ -31,9 +31,7 @@ describe OmniAuth::Strategies::GitHubOrganization do
31
31
  allow(subject).to receive(:organizations).and_return(%w[example test])
32
32
  end
33
33
 
34
- after do
35
- OmniAuth.config.test_mode = false
36
- end
34
+
37
35
 
38
36
  context 'client options' do
39
37
  it 'should have correct site' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-github-organization
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
  - Boris Ding