biola_wcms_components 0.25.1 → 0.25.2

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: 5f29ca233d7b9c38afa355bd466d740f5b2188ba
4
- data.tar.gz: b771c11af719e321462160be334c0d2e89ed515e
3
+ metadata.gz: 08f057cd72ef31f9c6c6859de0446819808e19af
4
+ data.tar.gz: a847ab856b8a12763358d884a6e0a9de105b79b8
5
5
  SHA512:
6
- metadata.gz: 924c1c3508a2f0362586af92b03f981d1cdaf9654689116bc60c86b5df97bd97912e883a3cc97864e647a0bb00271f916ba4f11de501e1d29d7ce8362f5db4a6
7
- data.tar.gz: c809523c4be832ad7e473cc3e89afc35efaac121fcd96c77f8bfe05a4cbbb728d4577a03ea7eea47492122c52612c4b07acea56a946c2cf33c3a03c871370122
6
+ metadata.gz: 5c41ec02388c8bac7bb2a73fb215fb3cccf3cc97ae1f734a983c04758b9c71eb47bdd9ca44efae26e1eda258d3d8e8b555a3f07d72d390619466121f0817be3f
7
+ data.tar.gz: a8fad43b098232738fd2423c7019e88c6292c3150297389f5ffcabe893a89e05815081e1012a10e830ff3958bc4af91523bea8a739e81993707b281cbdb23556
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### Master (unreleased)
4
4
 
5
+ ### 0.25.2
6
+
7
+ * Only update CAS attributes if they exist
8
+
5
9
  ### 0.25.1
6
10
 
7
11
  * Enforce extra attributes to be the right type
@@ -1,3 +1,3 @@
1
1
  module BiolaWcmsComponents
2
- VERSION = '0.25.1'.freeze
2
+ VERSION = '0.25.2'.freeze
3
3
  end
@@ -27,13 +27,13 @@ class CasAuthentication
27
27
  attr_reader :session
28
28
 
29
29
  USER_CAS_MAP = {
30
- biola_id: { employeeId: Integer },
31
- first_name: :eduPersonNickname,
32
- last_name: :sn,
33
- email: :mail,
34
- photo_url: :url,
35
- entitlements: { eduPersonEntitlement: Array },
36
- affiliations: { eduPersonAffiliation: Array }
30
+ employeeId: { biola_id: Integer },
31
+ eduPersonNickname: :first_name,
32
+ sn: :last_name,
33
+ mail: :email,
34
+ url: :photo_url,
35
+ eduPersonEntitlement: { entitlements: Array },
36
+ eduPersonAffiliation: { affiliations: Array }
37
37
  }.freeze
38
38
 
39
39
  def present?
@@ -57,9 +57,12 @@ class CasAuthentication
57
57
  end
58
58
 
59
59
  def update_extra_attributes!
60
- USER_CAS_MAP.each do |k, v|
61
- user[k] = attr_value(v, extra_attrs)
60
+ USER_CAS_MAP.each do |attr_key, opt|
61
+ next unless extra_attrs.key?(attr_key)
62
+ key, type = user_key_type(opt)
63
+ user[key] = attr_value(extra_attrs[attr_key], type)
62
64
  end
65
+
63
66
  user.save
64
67
  end
65
68
  alias create_user! update_extra_attributes!
@@ -76,17 +79,15 @@ class CasAuthentication
76
79
  @extra_attrs ||= (attrs[:extra_attributes] || {}).with_indifferent_access
77
80
  end
78
81
 
79
- def attr_value(key, opts = {})
80
- return String(opts[key]) if key.is_a? Symbol
81
- attr_hash(key, opts)
82
+ def attr_value(value, type = nil)
83
+ return Array(value).compact if type == Array
84
+ return Integer(value) if type == Integer &&
85
+ /\A\d+\z/ =~ value.to_s
86
+ String(value)
82
87
  end
83
88
 
84
- def attr_hash(hash, opts = {})
85
- return unless hash.is_a? Hash
86
-
87
- key, type = hash.first
88
- return Array(opts.try(:[], key)).compact if type == Array
89
- return Integer(opts.try(:[], key)) if type == Integer &&
90
- /\A\d+\z/ =~ opts[key].to_s
89
+ def user_key_type(opt)
90
+ return opt if opt.is_a? Symbol
91
+ opt.first
91
92
  end
92
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biola_wcms_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.1
4
+ version: 0.25.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Hall