doorkeeper_hub 0.1.3 → 0.1.4

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: cfb7d97ee1cdf3f2b3348d1d5cef1fb7100ccc4db37863111ce6e8f2554a2ebf
4
- data.tar.gz: 59c9fe7dd9c9d1d62063d1d0f162c4d42405a7372fc6e8d8a3ca127caaf522f1
3
+ metadata.gz: 57317b863c1df69f8ef98933a88adeefe67d16a9045b34a651f50040e7d0660a
4
+ data.tar.gz: 608d6f40b3f891882847825f615a537a32218be747eb4e754809b6d860349518
5
5
  SHA512:
6
- metadata.gz: 2e381ab5e9a1b0aebeed72bb03d4688ace0e3f2472ec35f8b0ff30b10d1c86f07659e422da68197bc45ece332e61a9d741dd1475f8b7bebf1d5e2bf45d86c349
7
- data.tar.gz: ab70a67c61aef22707756fb540c2702d8916a401b278cafd01a727e4ac7e80444b7022079156d30f86be2a8a6973b174dd3b45ed983d2efae79e508e4e7ccae9
6
+ metadata.gz: 9610fe1a924385f480ffde41a24ad5428b32ad838b9666398d11bc3073d06518d689a8e3f7b6e246b1330c68f475560d4ce3d97aeb13d601d1606ef7237173fc
7
+ data.tar.gz: dd9825328ded32b28d500813a530f6845f9a45710bb71dd955996f91c3aed67b05e3bb043a8650a009c8352a49ef4db0439db9ae1bda8c093d67bb0cc96021d1
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
@@ -16,7 +16,6 @@ module DoorkeeperHub
16
16
  raise(ActionController::RoutingError.new('Not Found'))
17
17
  end
18
18
 
19
-
20
19
  def check_login!
21
20
  redirect_to user_saml_omniauth_authorize_path unless user_signed_in?
22
21
  end
@@ -4,26 +4,36 @@ module DoorkeeperHub
4
4
  module Saml
5
5
  extend ActiveSupport::Concern
6
6
 
7
- def self.included(base)
8
- base.devise :omniauthable, omniauth_providers: %i[saml]
9
- end
10
-
11
- def instance_method
12
- puts "instance method here"
7
+ included do
8
+ devise :omniauthable, omniauth_providers: %i[saml]
13
9
  end
14
10
 
15
11
  class_methods do
16
12
  def from_omniauth(auth)
17
- companies = Company.where(doorkeeper_token: auth.extra.raw_info[:doorkeeper_token])
18
-
19
- return if companies.empty?
13
+ return if scope_results(auth).empty?
20
14
 
21
15
  user = where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
22
16
  user.email = auth.info.email
23
17
  end
24
- companies.each { |c| user.users_companies.find_or_create_by(company: c) }
18
+
19
+ scope_results(auth).each do |result|
20
+ user.users_companies.find_or_create_by(company: result)
21
+ end
22
+
25
23
  user
26
24
  end
25
+
26
+ def scope_results(auth)
27
+ @scope_results ||= DoorkeeperHub
28
+ .config.scope_model
29
+ .where(scope_query(auth))
30
+ end
31
+
32
+ def scope_query(auth)
33
+ {
34
+ DoorkeeperHub.token_name => auth.extra.raw_info[DoorkeeperHub.token_name]
35
+ }
36
+ end
27
37
  end
28
38
  end
29
39
  end
@@ -1,3 +1,3 @@
1
1
  module DoorkeeperHub
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeeper_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Fan