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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fe8a5dbe1dcaf7b9d576f8fa27e4eb818aa4c2e
|
4
|
+
data.tar.gz: ff6f9af85825f86a29e748d42a34f32a9e0b6bd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae79b578e1a4bd675bef51c269d8af6d33ba560c7b7c84b4d52f0c9ee536060ee6b36aadf140293b5816fa4d821ea5ca2f3d90ff03a5fcde243d2007850ad88a
|
7
|
+
data.tar.gz: 7fc06b2f353fad93cb28d9cdc105fa49ce781f435972f45c5888f65467477c42e8fea861b627588a87786923cb574330151b120f2eacc35249e93f9580adaa31
|
@@ -1,103 +1,52 @@
|
|
1
|
-
|
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 :
|
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
|
42
|
-
if registrar_profile =
|
43
|
-
|
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
|
48
|
-
session[
|
27
|
+
def store_current_profile(registrar_profile)
|
28
|
+
session[CURRENT_PROFILE_KEY] = YAML.dump(registrar_profile)
|
49
29
|
end
|
50
30
|
|
51
|
-
def
|
52
|
-
|
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
|
60
|
-
if
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|