registrar 0.0.3.alpha → 0.0.4.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a64176ce1c2a2b3a0a246db04ad66e6707375253
4
- data.tar.gz: bceee3818f7e9c13cf7d745909810303457e1b2e
3
+ metadata.gz: ed7d298c6e519757fc22a1fdf2f5773bd324988e
4
+ data.tar.gz: ec74198a299d71e6a22575bd1c22cec024a2b269
5
5
  SHA512:
6
- metadata.gz: 395eb4b97dfffec025633a8ba8d1b5dd5ba8f97c6aaa9d4876de0d1007bce933933564f035a944ef3d1256e11f9ab0383ae8f1e58561f013539012bdc495a6a9
7
- data.tar.gz: 6cea2612e132d060b7148d933cc078ed3967f4bccc248b8e0a4eee27081feda921db4e368f617b9e4338c5f0cea71e0606baf5b776fa90163b2420ab5ad5d607
6
+ metadata.gz: 67f803bd162d2c9da4b526df054d9f538a2dae50c7bf0719f0429a980d7f8ada2f5711779314f54c4082c9b2cf23ab49adfb99ce5376ecb73fa95562032c5e0f
7
+ data.tar.gz: 43c9cd8d02093266e7a80f598976a67b7eec93c80b9b4a91def73442b76f501f7e6fdf486d0193e343b18307e6442570e4a8f9d2fd88db25aa97ef28c9ebc287
@@ -40,12 +40,24 @@ module Registrar
40
40
 
41
41
  def normalize_provider
42
42
  {
43
- 'name' => auth['provider'],
44
- 'uid' => auth['uid'],
45
- 'access_token' => auth['credentials']['token']
43
+ 'name' => provider_name,
44
+ 'uid' => provider_uid,
45
+ 'access_token' => access_token
46
46
  }
47
47
  end
48
48
 
49
+ def provider_name
50
+ auth['provider']
51
+ end
52
+
53
+ def provider_uid
54
+ auth['uid']
55
+ end
56
+
57
+ def access_token
58
+ auth['credentials']['token']
59
+ end
60
+
49
61
  def normalize_profile
50
62
  auth['info'].to_hash
51
63
  end
@@ -7,6 +7,19 @@ module Registrar
7
7
  def self.included(klass)
8
8
  klass.include InstanceMethods
9
9
  klass.before_action :try_to_store_registrar_profile
10
+
11
+ klass.class_eval do
12
+ helper_method :current_profile
13
+ helper_method :current_profile?
14
+ helper_method :logged_in?
15
+
16
+ helper_method :registrar_profile
17
+ helper_method :registrar_profile?
18
+
19
+ helper_method :authentication_phase?
20
+
21
+ helper_method :presentable_authentication
22
+ end
10
23
  end
11
24
 
12
25
  module InstanceMethods
@@ -27,6 +40,11 @@ module Registrar
27
40
  try_to_set_current_profile
28
41
  end
29
42
 
43
+ def current_profile?
44
+ !!current_profile
45
+ end
46
+ alias_method :logged_in?, :current_profile?
47
+
30
48
  def try_to_set_current_profile
31
49
  if registrar_profile?
32
50
  @current_user = build_profile(registrar_profile)
@@ -44,6 +62,20 @@ module Registrar
44
62
  def build_profile(profile)
45
63
  ::Registrar::Profile.new(profile)
46
64
  end
65
+
66
+ def authentication_phase?
67
+ params[:controller] == 'authentication' && params[:action] = 'callback'
68
+ end
69
+
70
+ def presentable_authentication
71
+ {
72
+ 'env.omniauth.auth' => request.env['omniauth.auth'],
73
+ 'env.registrar.auth' => request.env['registrar.auth'],
74
+ 'env.registrar.profile' => request.env['registrar.profile'],
75
+ 'session.registrar_profile' => registrar_profile,
76
+ 'runtime.current_profile' => current_profile
77
+ }
78
+ end
47
79
  end
48
80
  end
49
81
  end
@@ -1,3 +1,3 @@
1
1
  module Registrar
2
- VERSION = "0.0.3.alpha"
2
+ VERSION = "0.0.4.alpha"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: registrar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.alpha
4
+ version: 0.0.4.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-03-11 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler