registrar-rails 0.1.0.alpha → 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
  SHA1:
3
- metadata.gz: 2f36923d9b6c4c211f9793f90b9d0f96c85c6911
4
- data.tar.gz: d8cdd0cfb9c99d4094adf1b1b5fb36982a706145
3
+ metadata.gz: 63b952e593becaf35f3cdf23aca956d29bb6f38f
4
+ data.tar.gz: b95dbd8baac6bb446e962bbd964f2890f999a962
5
5
  SHA512:
6
- metadata.gz: fc76cc7d8000abca939d10f814777e42f8a202f8a2c0221ddba802ee2248039a6e72df122cfcd3aeabe6e9ef55aaa6f26a3c78c61eff0a94d9f9c79221071714
7
- data.tar.gz: b5719556812ca6c090dc9fbc75d41736ea6872951d5b7524644d72573513d9f0a9de04001d3ce7d820e8186e19c1cde96ed591ea2a3a3dcab22665993982d7fb
6
+ metadata.gz: 71e9b85cd98b542caacdd1aeb54c023bdb446c43b4f75c6b46ebeb87017ba7712c6234725bb14135bc5a3088a4bce96b437173adab592e6bb417f5079a0f8000
7
+ data.tar.gz: 6e62c6519aa9fb15529ce0fcf78f6a333dbe70a376b24791a27999b6873fefc9be263839d268565a5f894a4f39750545595e459c36d189d58673a2f1cff04310
@@ -0,0 +1,7 @@
1
+ class RegistrarController < ApplicationController
2
+ skip_before_action :verify_authenticity_token
3
+
4
+ def callback
5
+ redirect_to after_auth_url
6
+ end
7
+ end
data/config/routes.rb CHANGED
@@ -1,8 +1,4 @@
1
1
  Rails.application.routes.draw do
2
- get 'sign_up', :to => 'authentication#sign_up', :as => 'sign_up'
3
- get 'sign_in', :to => 'authentication#sign_in', :as => 'sign_in'
4
-
5
- # Auth through OmniAuth strategy
6
- post 'auth/:strategy/callback' => 'authentication#authenticate'
7
- get 'auth/:strategy/callback' => 'authentication#authenticate'
2
+ # Delegate all OmniAuth callbacks to Registrar
3
+ match 'auth/:strategy/callback' => 'registrar#callback', :via => [:get, :post]
8
4
  end
@@ -8,7 +8,7 @@ module Registrar
8
8
  klass.class_eval do
9
9
  helper_method :current_profile
10
10
  helper_method :current_profile?
11
- helper_method :logout
11
+ helper_method :sign_out_current_profile
12
12
  end
13
13
  end
14
14
 
@@ -22,19 +22,9 @@ module Registrar
22
22
  end
23
23
  end
24
24
 
25
- def logout
26
- session[CURRENT_PROFILE_UID] = nil
27
- end
28
-
29
25
  def current_profile
30
26
  return @current_profile if @current_profile
31
-
32
- if current_profile_uid_from_session
33
- @current_profile = Registrar::Middleware::config.handler.call(
34
- build_current_profile
35
- )
36
- end
37
-
27
+ @current_profile = handle(profile) if current_profile_uid_from_session
38
28
  @current_profile
39
29
  end
40
30
 
@@ -42,8 +32,8 @@ module Registrar
42
32
  !!current_profile
43
33
  end
44
34
 
45
- def authentication_phase?
46
- params[:controller] == 'authentication' && params[:action] = 'callback'
35
+ def sign_out_current_profile
36
+ session[CURRENT_PROFILE_UID] = nil
47
37
  end
48
38
 
49
39
  private
@@ -56,7 +46,11 @@ module Registrar
56
46
  session[CURRENT_PROFILE_UID]
57
47
  end
58
48
 
59
- def build_current_profile
49
+ def handle(profile)
50
+ Registrar::Middleware::config.handler.call(profile)
51
+ end
52
+
53
+ def profile
60
54
  {
61
55
  "provider" => {
62
56
  "name" => "session",
@@ -17,6 +17,10 @@ module Registrar
17
17
  block = lambda do |config|
18
18
  configuration.call config
19
19
  config.middleware(::Rails.application.config.middleware)
20
+
21
+ OmniAuth.config.on_failure = Proc.new { |env|
22
+ # noop - lat the application handle the error
23
+ }
20
24
  end
21
25
 
22
26
  @@configuration = lambda do
@@ -1,5 +1,5 @@
1
1
  module Registrar
2
2
  module Rails
3
- VERSION = "0.1.0.alpha"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -896,3 +896,39 @@ CurrentProfileTest: test_exposes_current_profile_if_registrar.profile_is_avaliab
896
896
  Started GET "/" for 127.0.0.1 at 2015-06-02 17:24:43 +0200
897
897
  Processing by SomeController#index as HTML
898
898
  Completed 200 OK in 14ms (Views: 0.2ms)
899
+ ----------------------------------------------------------------------------------
900
+ CurrentProfileTest: test_exposes_current_profile_if_registrar.profile_is_avaliable
901
+ ----------------------------------------------------------------------------------
902
+ Started GET "/" for 127.0.0.1 at 2015-12-02 11:00:51 +0100
903
+ Processing by SomeController#index as HTML
904
+ Completed 200 OK in 16ms (Views: 0.2ms)
905
+ ----------------------------------------------------------------------------------
906
+ CurrentProfileTest: test_exposes_current_profile_if_registrar.profile_is_avaliable
907
+ ----------------------------------------------------------------------------------
908
+ Started GET "/" for 127.0.0.1 at 2015-12-02 11:03:25 +0100
909
+ Processing by SomeController#index as HTML
910
+ Completed 200 OK in 14ms (Views: 0.1ms)
911
+ ----------------------------------------------------------------------------------
912
+ CurrentProfileTest: test_exposes_current_profile_if_registrar.profile_is_avaliable
913
+ ----------------------------------------------------------------------------------
914
+ Started GET "/" for 127.0.0.1 at 2015-12-02 11:06:23 +0100
915
+ Processing by SomeController#index as HTML
916
+ Completed 200 OK in 14ms (Views: 0.1ms)
917
+ ----------------------------------------------------------------------------------
918
+ CurrentProfileTest: test_exposes_current_profile_if_registrar.profile_is_avaliable
919
+ ----------------------------------------------------------------------------------
920
+ Started GET "/" for 127.0.0.1 at 2015-12-02 11:34:25 +0100
921
+ Processing by SomeController#index as HTML
922
+ Completed 200 OK in 14ms (Views: 0.1ms)
923
+ ----------------------------------------------------------------------------------
924
+ CurrentProfileTest: test_exposes_current_profile_if_registrar.profile_is_avaliable
925
+ ----------------------------------------------------------------------------------
926
+ Started GET "/" for 127.0.0.1 at 2015-12-02 12:37:02 +0100
927
+ Processing by SomeController#index as HTML
928
+ Completed 200 OK in 14ms (Views: 0.2ms)
929
+ ----------------------------------------------------------------------------------
930
+ CurrentProfileTest: test_exposes_current_profile_if_registrar.profile_is_avaliable
931
+ ----------------------------------------------------------------------------------
932
+ Started GET "/" for 127.0.0.1 at 2015-12-02 14:18:24 +0100
933
+ Processing by SomeController#index as HTML
934
+ Completed 200 OK in 14ms (Views: 0.2ms)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: registrar-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Owiesniak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -46,7 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - Rakefile
49
- - app/controllers/authentication_controller.rb
49
+ - app/controllers/registrar_controller.rb
50
50
  - config/initializers/registrar.rb
51
51
  - config/routes.rb
52
52
  - lib/registrar-rails.rb
@@ -95,9 +95,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - ">"
98
+ - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: 1.3.1
100
+ version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
103
  rubygems_version: 2.2.2
@@ -1,13 +0,0 @@
1
- class AuthenticationController < ApplicationController
2
- skip_before_action :verify_authenticity_token
3
-
4
- def sign_in
5
- end
6
-
7
- def sign_up
8
- end
9
-
10
- def authenticate
11
- redirect_to '/'
12
- end
13
- end