doorkeeper_hub 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f70c3114ac23d14dffe588b16c1a7455eaf7e7e9e349c314f4e833241e9eed6
4
- data.tar.gz: 31870d832f5fc2f993df9bc7c63e697db5be524b3241dd3cef2464b1ca51deb0
3
+ metadata.gz: 2003e63a8f06385f671a2d721627f464a1674ab5d5c59133f0bbd4ce0a330b07
4
+ data.tar.gz: cdc61a7e345792ba6237786b1d890cfa55be0d3d03775292a102ce03a5dcfed0
5
5
  SHA512:
6
- metadata.gz: ab007e60bd466f83779c536f3815903fee9973c9ee67bf4fe2678961cd24a7e324070f3ade514505d22ea4bac080a6285850dc8c96a190e865646c44c2205b7d
7
- data.tar.gz: 78b91d725dba5dc9b4a04087a0750d68cac85ded855a1c5179e8bbcedd02b7d6669184f6c73ab7300d00dd0ee707701f665f304c8e5359ee7877e2e19dace76f
6
+ metadata.gz: bb1be655cc62257997527740ce6cd1fcf32cb194ea2acb75bb03f316c780cf708579b7ddf87cebd83293de561fbbc1a64d2b43ab05e42c2ee0b5583a952e8cd3
7
+ data.tar.gz: 81833e76cce3e967975c4010c8c4c1fa15a0a138df04bc0c672d601f158b6a2c680669449e0edd7471bcb4e97eb7b46f048adbf02d891c8fab04894ab52993ca
data/config/routes.rb CHANGED
@@ -4,5 +4,7 @@ Rails.application.routes.draw do
4
4
  omniauth_callbacks: 'doorkeeper_hub/omniauth_callbacks'
5
5
  }
6
6
 
7
- post 'doorkeeper/activation', to: 'doorkeeper_hub/callbacks#activation'
7
+ unless DoorkeeperHub.client_mode?
8
+ post 'doorkeeper/activation', to: 'doorkeeper_hub/callbacks#activation'
9
+ end
8
10
  end
@@ -4,12 +4,14 @@ module DoorkeeperHub
4
4
  attr_accessor :scope_model
5
5
  attr_accessor :user_model
6
6
  attr_accessor :doorkeeper_token_name
7
+ attr_accessor :client_mode
7
8
 
8
9
  def initialize
9
10
  self.service_token = ENV["SERVICE_TOKEN"]
10
11
  self.scope_model = ::Company
11
12
  self.user_model = ::User
12
13
  self.doorkeeper_token_name = :doorkeeper_token
14
+ self.client_mode = false
13
15
  end
14
16
  end
15
17
  end
@@ -3,11 +3,13 @@ module DoorkeeperHub
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- before_action :authenticate_doorkeeper!
6
+ before_action :authenticate_doorkeeper!, unless: -> { DoorkeeperHub.client_mode? }
7
7
  end
8
8
 
9
9
  def authenticate_doorkeeper!
10
10
  if signed_in?(DoorkeeperHub.devise_scope)
11
+ return if DoorkeeperHub.client_mode?
12
+
11
13
  redirect_to root_path_with_token if params[DoorkeeperHub.token_param].nil?
12
14
  else
13
15
  redirect_to omniauth_authorize_path(
@@ -18,6 +20,8 @@ module DoorkeeperHub
18
20
  end
19
21
 
20
22
  def default_url_options(options = {})
23
+ return options if DoorkeeperHub.client_mode?
24
+
21
25
  options[DoorkeeperHub.token_param] = params[DoorkeeperHub.token_param]
22
26
  options
23
27
  end
@@ -10,14 +10,16 @@ module DoorkeeperHub
10
10
 
11
11
  class_methods do
12
12
  def from_omniauth(auth)
13
- return if scope_results(auth).empty?
13
+ return if DoorkeeperHub.client_mode? && scope_results(auth).empty?
14
14
 
15
15
  user = where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
16
16
  user.email = auth.info.email
17
17
  end
18
18
 
19
- scope_results(auth).each do |result|
20
- user.users_companies.find_or_create_by(company: result)
19
+ unless DoorkeeperHub.client_mode?
20
+ scope_results(auth).each do |result|
21
+ user.users_companies.find_or_create_by(company: result)
22
+ end
21
23
  end
22
24
 
23
25
  user
@@ -1,3 +1,3 @@
1
1
  module DoorkeeperHub
2
- VERSION = "0.1.7"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -32,4 +32,8 @@ module DoorkeeperHub
32
32
  def self.token_param
33
33
  :doorkeeper_token
34
34
  end
35
+
36
+ def self.client_mode?
37
+ config.client_mode
38
+ end
35
39
  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.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Fan