ucb_rails_user 4.1.1 → 4.1.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
  SHA256:
3
- metadata.gz: 7a1de8958c36cbeeb3541649d812e7288468672f9352ec84749810fccaf81005
4
- data.tar.gz: e2262f788179205abf8dc7d4558a434f3826130f6d713448ef90a783e2341fe1
3
+ metadata.gz: a2d32568b7c7c44c29b420b560c94db14a5cef2150e40e69b535cc9fad3b6714
4
+ data.tar.gz: 7325bbb7ee1f6cd3ea3a04c7f38411d5e75551c31022260ba454d22769c60d2d
5
5
  SHA512:
6
- metadata.gz: 27314e556fa6987b12779ea570dacbd3f5089a7cfdef91a316020f13754ceb147cd74de4e3e468a298109cc1336beef659708507bde98605743242e9cd4f6c91
7
- data.tar.gz: dbb93ff5a2cde7347e2b5441155edafae6f18557cbaf584ac6f89fdb34adda7b67dc36b8f43a5c571e2fb0b6de8eefd71dacb6f3a3e6cd04458a56acd1d417fe
6
+ metadata.gz: efb9dd7b036a5de8251cab4068172cea5fdcce1db57be780d0e70111d90b634dc591a09fadc8b81206a6005f6d2b4a59cc63b31d729716abfc3a396492567b82
7
+ data.tar.gz: 7f0beaa12b968857a56c1c6a8966c51a77447f975c88494c5e6c4022d5ad712b7be085c91c6a0ab267d3d454de9cfd38b5f979c61becc2c3812d2853dfb224d7
@@ -14,6 +14,7 @@ module UcbRailsUser::LdapPerson
14
14
  attribute :first_name
15
15
  attribute :last_name
16
16
  attribute :email
17
+ attribute :alternate_email
17
18
  attribute :phone
18
19
  attribute :departments
19
20
  attribute :affiliations
@@ -40,19 +41,23 @@ module UcbRailsUser::LdapPerson
40
41
  class << self
41
42
 
42
43
  def new_from_ldap_entry(ldap_entry)
44
+ # the to_s calls are because the underlying LDAP library sometimes returns strings as instances
45
+ # of Net::BER::BerIdentifiedString rather than String, and the Oracle DB library doesn't play
46
+ # nicely with those (postgres and sqlite work fine)
43
47
  new(
44
- :uid => ldap_entry.uid,
45
- :calnet_id => ldap_entry.berkeleyedukerberosprincipalstring.first,
46
- :employee_id => ldap_entry.attributes[:berkeleyeduucpathid]&.first,
47
- :student_id => ldap_entry.berkeleyedustuid,
48
- :first_name => ldap_entry.givenname.first,
49
- :last_name => ldap_entry.sn.first,
50
- :email => ldap_entry.mail.first,
51
- :phone => ldap_entry.phone,
52
- :departments => ldap_entry.berkeleyeduunithrdeptname,
53
- :affiliations => ldap_entry.berkeleyeduaffiliations,
54
- :affiliate_id => ldap_entry.berkeleyeduaffid.first,
55
- :inactive => ldap_entry.expired? || false
48
+ uid: ldap_entry.uid&.to_s,
49
+ calnet_id: ldap_entry.berkeleyedukerberosprincipalstring.first&.to_s,
50
+ employee_id: ldap_entry.attributes[:berkeleyeduucpathid]&.first&.to_s,
51
+ student_id: ldap_entry.berkeleyedustuid&.to_s,
52
+ first_name: ldap_entry.givenname.first&.to_s,
53
+ last_name: ldap_entry.sn.first&.to_s,
54
+ email: ldap_entry.mail.first&.to_s,
55
+ alternate_email: ldap_entry.attributes[:berkeleyeduofficialemail]&.first&.to_s,
56
+ phone: ldap_entry.phone&.to_s,
57
+ departments: ldap_entry.berkeleyeduunithrdeptname&.to_s,
58
+ affiliations: ldap_entry.berkeleyeduaffiliations&.map(&:to_s),
59
+ affiliate_id: ldap_entry.berkeleyeduaffid.first&.to_s,
60
+ inactive: ldap_entry.expired? || false
56
61
  )
57
62
  end
58
63
 
@@ -8,6 +8,9 @@ module UcbRailsUser
8
8
 
9
9
  if people_ou_entry.present?
10
10
  UcbRailsUser::UserLdapService.create_or_update_user_from_entry(people_ou_entry).tap do |user|
11
+ if missing_or_invalid_email?(user)
12
+ user.update(email: people_ou_entry.alternate_email) if people_ou_entry.alternate_email.present?
13
+ end
11
14
  user.touch(:last_login_at)
12
15
  end
13
16
  else
@@ -15,6 +18,12 @@ module UcbRailsUser
15
18
  end
16
19
  end
17
20
 
21
+ private
22
+
23
+ def missing_or_invalid_email?(user)
24
+ user&.email.blank? || (user.email =~ URI::MailTo::EMAIL_REGEXP).nil?
25
+ end
26
+
18
27
  end
19
28
 
20
29
  end
@@ -1,3 +1,3 @@
1
1
  module UcbRailsUser
2
- VERSION = '4.1.1'
2
+ VERSION = '4.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucb_rails_user
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Downey
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-09-14 00:00:00.000000000 Z
14
+ date: 2022-10-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails