doorkeeper_hub 0.1.4 → 0.1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50b7e28e158b353429f556bb4f171ce8d385ff44cd20105c1450d2a2f82dc6ae
|
4
|
+
data.tar.gz: 892dd0510930e88cb8d113ca099db81b3c5ec026818d4abbd3dbdf5da7679ef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae0b8aa90bc7886c2ac279d7b2a674129b320fa9f7a2084c07708b2ee3214dfe11174ded731f6f4f414a1656033b7d4b65c4345def6b3bd3fa0f38ed9bca33da
|
7
|
+
data.tar.gz: 168d6a716b87ed915dcd2755e08db3f70ab2ba42e8ff6eaeb0ee05986052288c3bb56d5f4fc9a2b1bbf2e45e883d0597633a42e3225e83557f26ba320113a4fd
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module DoorkeeperHub
|
2
2
|
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
3
3
|
skip_before_action :verify_authenticity_token,
|
4
|
-
:
|
5
|
-
:check_d_token, only: :saml
|
4
|
+
:authenticate_doorkeeper!, only: :saml
|
6
5
|
|
7
6
|
def saml
|
8
7
|
@user = DoorkeeperHub
|
data/config/routes.rb
CHANGED
@@ -3,25 +3,17 @@ module DoorkeeperHub
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
before_action :
|
6
|
+
before_action :authenticate_doorkeeper!
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def check_login!
|
20
|
-
redirect_to user_saml_omniauth_authorize_path unless user_signed_in?
|
21
|
-
end
|
22
|
-
|
23
|
-
def after_sign_in_path_for(current_user)
|
24
|
-
root_path(d_token: params_or_default_d_token)
|
9
|
+
def authenticate_doorkeeper!
|
10
|
+
if signed_in?(DoorkeeperHub.devise_scope)
|
11
|
+
redirect_to root_path_with_token if params[:d_token].nil?
|
12
|
+
else
|
13
|
+
redirect_to omniauth_authorize_path(
|
14
|
+
DoorkeeperHub.devise_scope, :saml
|
15
|
+
)
|
16
|
+
end
|
25
17
|
end
|
26
18
|
|
27
19
|
def default_url_options(options = {})
|
@@ -29,14 +21,22 @@ module DoorkeeperHub
|
|
29
21
|
options
|
30
22
|
end
|
31
23
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
def after_sign_in_path_for(_)
|
25
|
+
root_path_with_token
|
26
|
+
end
|
27
|
+
|
28
|
+
def root_path_with_token
|
29
|
+
root_path d_token: params_or_default_d_token
|
36
30
|
end
|
37
31
|
|
38
32
|
def params_or_default_d_token
|
39
33
|
params[:d_token] || current_user.companies.first.doorkeeper_token
|
40
34
|
end
|
35
|
+
|
36
|
+
def company
|
37
|
+
@company ||=
|
38
|
+
current_user.companies.active.find_by(doorkeeper_token: params[:d_token]) ||
|
39
|
+
raise(ActionController::RoutingError.new('Not Found'))
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/doorkeeper_hub.rb
CHANGED
@@ -13,8 +13,12 @@ module DoorkeeperHub
|
|
13
13
|
yield config
|
14
14
|
end
|
15
15
|
|
16
|
+
def self.devise_routes_scope
|
17
|
+
user_model.to_s.downcase.pluralize.to_sym
|
18
|
+
end
|
19
|
+
|
16
20
|
def self.devise_scope
|
17
|
-
|
21
|
+
user_model.to_s.downcase.to_sym
|
18
22
|
end
|
19
23
|
|
20
24
|
def self.user_model
|