doorkeeper_hub 0.1.2 → 0.1.3

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: e0323f1e027ab3321e8a50037d70ecf9bb7f98f15b0c5d88080870031d20fb71
4
- data.tar.gz: d42bd09e2885ac4c4818f3563c8f144bf7dd8c4c1cdefd91c34625d1c8fc4c73
3
+ metadata.gz: cfb7d97ee1cdf3f2b3348d1d5cef1fb7100ccc4db37863111ce6e8f2554a2ebf
4
+ data.tar.gz: 59c9fe7dd9c9d1d62063d1d0f162c4d42405a7372fc6e8d8a3ca127caaf522f1
5
5
  SHA512:
6
- metadata.gz: 05d6ebb3327da326b0bad77c7d06c0d2d423370f2ea2304777a42122133da11b02e86e631febe19b2aa2666c6f17e7cbe1b04b151454436c9264974deefc8f52
7
- data.tar.gz: 933017e512524a9dd518e02e788399e715f63e3a736004de8e8cb7f2014b41c12d6d0adcffc6a6d78978687b0223401fb26ce89d3f2b25dceb01e808502c7068
6
+ metadata.gz: 2e381ab5e9a1b0aebeed72bb03d4688ace0e3f2472ec35f8b0ff30b10d1c86f07659e422da68197bc45ece332e61a9d741dd1475f8b7bebf1d5e2bf45d86c349
7
+ data.tar.gz: ab70a67c61aef22707756fb540c2702d8916a401b278cafd01a727e4ac7e80444b7022079156d30f86be2a8a6973b174dd3b45ed983d2efae79e508e4e7ccae9
@@ -1,3 +1,5 @@
1
+ require 'doorkeeper_hub/routes'
2
+
1
3
  module DoorkeeperHub
2
4
  class Engine < Rails::Engine
3
5
  end
@@ -0,0 +1,43 @@
1
+ module DoorkeeperHub
2
+ module Helpers
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ before_action :check_login!, :check_d_token
7
+ end
8
+
9
+ def check_login!
10
+ redirect_to user_saml_omniauth_authorize_path unless user_signed_in?
11
+ end
12
+
13
+ def company
14
+ @company ||=
15
+ current_user.companies.active.find_by(doorkeeper_token: params[:d_token]) ||
16
+ raise(ActionController::RoutingError.new('Not Found'))
17
+ end
18
+
19
+
20
+ def check_login!
21
+ redirect_to user_saml_omniauth_authorize_path unless user_signed_in?
22
+ end
23
+
24
+ def after_sign_in_path_for(current_user)
25
+ root_path(d_token: params_or_default_d_token)
26
+ end
27
+
28
+ def default_url_options(options = {})
29
+ options[:d_token] = params[:d_token]
30
+ options
31
+ end
32
+
33
+ def check_d_token
34
+ if params[:d_token].nil? && current_user.present?
35
+ redirect_to root_path d_token: params_or_default_d_token
36
+ end
37
+ end
38
+
39
+ def params_or_default_d_token
40
+ params[:d_token] || current_user.companies.first.doorkeeper_token
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,14 @@
1
+ module DoorkeeperHub
2
+ module ActionDispatch::Routing
3
+ class RouteSet #:nodoc:
4
+ end
5
+
6
+ class Mapper
7
+ def doorkeeper
8
+ scope '/:d_token' do
9
+ yield
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module DoorkeeperHub
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "doorkeeper_hub/version"
2
2
  require 'doorkeeper_hub/configurator'
3
3
  require "doorkeeper_hub/saml"
4
+ require "doorkeeper_hub/helpers"
4
5
  require 'doorkeeper_hub/engine' if defined?(::Rails) && Rails::VERSION::MAJOR > 4
5
6
 
6
7
  module DoorkeeperHub
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Fan
@@ -88,6 +88,8 @@ files:
88
88
  - lib/doorkeeper_hub.rb
89
89
  - lib/doorkeeper_hub/configurator.rb
90
90
  - lib/doorkeeper_hub/engine.rb
91
+ - lib/doorkeeper_hub/helpers.rb
92
+ - lib/doorkeeper_hub/routes.rb
91
93
  - lib/doorkeeper_hub/saml.rb
92
94
  - lib/doorkeeper_hub/version.rb
93
95
  homepage: https://devhub.co