registrar-rails 0.0.6.alpha → 0.0.7.alpha

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: fa7fa9e54f0d296ddddfb684a048abead36e1c43
4
- data.tar.gz: a6741039bfa8fb201098a1ce8293c7330f187b48
3
+ metadata.gz: 5fe8a5dbe1dcaf7b9d576f8fa27e4eb818aa4c2e
4
+ data.tar.gz: ff6f9af85825f86a29e748d42a34f32a9e0b6bd7
5
5
  SHA512:
6
- metadata.gz: 342d948ff27c8168b94ee7fded06c3c86b23ce337af8be2b2c96087c4f318d9c0c6e17ea3a1a9d8f702c35f3c6ff5750b0645364e8ee05c163d74d78367abfa6
7
- data.tar.gz: a616424cbf7d2c7bcff40882bfe2cc802974e5d08bdbe4c55257fd26049a124f4b7f83584567dd9bc4ff881f8a0dafb1d61065daeda67be7af5390df4288d45d
6
+ metadata.gz: ae79b578e1a4bd675bef51c269d8af6d33ba560c7b7c84b4d52f0c9ee536060ee6b36aadf140293b5816fa4d821ea5ca2f3d90ff03a5fcde243d2007850ad88a
7
+ data.tar.gz: 7fc06b2f353fad93cb28d9cdc105fa49ce781f435972f45c5888f65467477c42e8fea861b627588a87786923cb574330151b120f2eacc35249e93f9580adaa31
@@ -1,4 +1,6 @@
1
1
  class AuthenticationController < ApplicationController
2
+ skip_before_action :verify_authenticity_token
3
+
2
4
  def sign_in
3
5
  end
4
6
 
@@ -1,103 +1,52 @@
1
- module Registrar
2
- class Profile < Delegator
3
- def initialize(obj)
4
- super
5
- @delegate_sd_obj = obj
6
- end
7
-
8
- def __getobj__
9
- @delegate_sd_obj
10
- end
11
-
12
- def __setobj__(obj)
13
- @delegate_sd_obj = obj
14
- end
15
- end
1
+ require 'yaml'
16
2
 
3
+ module Registrar
17
4
  module Rails
18
5
  module ControllerExtensions
19
6
  def self.included(klass)
20
7
  klass.send :include, InstanceMethods
21
- klass.before_action :try_to_store_registrar_profile
8
+ klass.before_action :try_to_store_current_profile
22
9
 
23
10
  klass.class_eval do
24
11
  helper_method :current_profile
25
12
  helper_method :current_profile?
26
- helper_method :logged_in?
27
-
28
- helper_method :registrar_profile
29
- helper_method :registrar_profile?
30
-
31
- helper_method :authentication_phase?
32
-
33
13
  helper_method :logout
34
- helper_method :presentable_authentication
35
14
  end
36
15
  end
37
16
 
38
17
  module InstanceMethods
39
18
  REGISTRAR_PROFILE_KEY = 'registrar.profile'
19
+ CURRENT_PROFILE_KEY = 'current.profile'
40
20
 
41
- def try_to_store_registrar_profile
42
- if registrar_profile = request.env['registrar.profile']
43
- store_registrar_profile(registrar_profile)
21
+ def try_to_store_current_profile
22
+ if registrar_profile = env[REGISTRAR_PROFILE_KEY]
23
+ store_current_profile(registrar_profile)
44
24
  end
45
25
  end
46
26
 
47
- def store_registrar_profile(registrar_profile)
48
- session[REGISTRAR_PROFILE_KEY] = registrar_profile
27
+ def store_current_profile(registrar_profile)
28
+ session[CURRENT_PROFILE_KEY] = YAML.dump(registrar_profile)
49
29
  end
50
30
 
51
- def current_profile
52
- if registrar_profile?
53
- @current_profile = build_profile(registrar_profile)
54
- else
55
- @current_profile
56
- end
31
+ def logout
32
+ session[CURRENT_PROFILE_KEY] = nil
57
33
  end
58
34
 
59
- def reload_current_profile
60
- if registrar_profile?
61
- reloaded_profile = Registrar::Middleware::config.handler.call(registrar_profile)
62
- request.env['registrar.profile'] = reloaded_profile
63
- try_to_store_registrar_profile
35
+ def current_profile
36
+ if session[CURRENT_PROFILE_KEY]
37
+ YAML.load session[CURRENT_PROFILE_KEY]
38
+ else
39
+ nil
64
40
  end
65
41
  end
66
42
 
67
- def logout
68
- @current_profile = nil
69
- end
70
-
71
43
  def current_profile?
72
44
  !!current_profile
73
45
  end
74
- alias_method :logged_in?, :current_profile?
75
-
76
- def registrar_profile?
77
- !!registrar_profile
78
- end
79
-
80
- def registrar_profile
81
- session[REGISTRAR_PROFILE_KEY]
82
- end
83
-
84
- def build_profile(profile)
85
- ::Registrar::Profile.new(profile)
86
- end
87
46
 
88
47
  def authentication_phase?
89
48
  params[:controller] == 'authentication' && params[:action] = 'callback'
90
49
  end
91
-
92
- def presentable_authentication
93
- {
94
- 'env.omniauth.auth' => request.env['omniauth.auth'],
95
- 'env.registrar.auth' => request.env['registrar.auth'],
96
- 'env.registrar.profile' => request.env['registrar.profile'],
97
- 'session.registrar_profile' => registrar_profile,
98
- 'runtime.current_profile' => current_profile
99
- }
100
- end
101
50
  end
102
51
  end
103
52
  end
@@ -1,5 +1,5 @@
1
1
  module Registrar
2
2
  module Rails
3
- VERSION = "0.0.6.alpha"
3
+ VERSION = "0.0.7.alpha"
4
4
  end
5
5
  end
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.0.6.alpha
4
+ version: 0.0.7.alpha
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-04-14 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails