Class: UcbRails::UserLdapService
- Inherits:
-
Object
- Object
- UcbRails::UserLdapService
- Defined in:
- app/models/ucb_rails/user_ldap_service.rb
Class Method Summary collapse
- .create_or_update_user(uid) ⇒ Object
- .create_or_update_user_from_entry(entry) ⇒ Object
- .create_user_from_ldap_entry(ldap_entry) ⇒ Object
- .create_user_from_uid(uid) ⇒ Object
- .update_user_from_ldap_entry(ldap_entry) ⇒ Object
- .update_user_from_uid(uid) ⇒ Object
Class Method Details
.create_or_update_user(uid) ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/models/ucb_rails/user_ldap_service.rb', line 43 def create_or_update_user(uid) if user = UcbRails::User.find_by_uid(uid) update_user_from_uid(uid) else create_user_from_uid(uid) end end |
.create_or_update_user_from_entry(entry) ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/models/ucb_rails/user_ldap_service.rb', line 51 def create_or_update_user_from_entry(entry) if user = UcbRails::User.find_by_uid(entry.uid) update_user_from_ldap_entry(entry) else create_user_from_ldap_entry(entry) end end |
.create_user_from_ldap_entry(ldap_entry) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/ucb_rails/user_ldap_service.rb', line 12 def create_user_from_ldap_entry(ldap_entry) UcbRails.logger.debug "create_user_from_ldap_entry #{ldap_entry.uid}" UcbRails::User.create! do |u| u.uid = ldap_entry.uid u.first_name = ldap_entry.first_name u.last_name = ldap_entry.last_name u.email = ldap_entry.email u.phone = ldap_entry.phone end end |
.create_user_from_uid(uid) ⇒ Object
5 6 7 8 9 10 |
# File 'app/models/ucb_rails/user_ldap_service.rb', line 5 def create_user_from_uid(uid) UcbRails.logger.debug "create_user_from_uid #{uid}" ldap_entry = UcbRails::LdapPerson::Finder.find_by_uid!(uid) create_user_from_ldap_entry(ldap_entry) end |
.update_user_from_ldap_entry(ldap_entry) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/ucb_rails/user_ldap_service.rb', line 31 def update_user_from_ldap_entry(ldap_entry) UcbRails.logger.debug "update_user_from_ldap_entry #{ldap_entry.uid}" UcbRails::User.find_by_uid!(ldap_entry.uid).tap do |user| user.first_name = ldap_entry.first_name user.last_name = ldap_entry.last_name user.email = ldap_entry.email user.phone = ldap_entry.phone user.save(validate: false) end end |
.update_user_from_uid(uid) ⇒ Object
24 25 26 27 28 29 |
# File 'app/models/ucb_rails/user_ldap_service.rb', line 24 def update_user_from_uid(uid) UcbRails.logger.debug "update_user_from_uid #{uid}" ldap_entry = UcbRails::LdapPerson::Finder.find_by_uid!(uid) update_user_from_ldap_entry(ldap_entry) end |