Sha256: a2dcdfc156af3129ebce190caf54d19def1efceb6dc4bc51789ff481b9db0a0b

Contents?: true

Size: 731 Bytes

Versions: 8

Compression:

Stored size: 731 Bytes

Contents

module UcbRailsUser
  module UserSessionManager

    class InPeopleOuAddToUsersTable < ActiveInUserTable

      def login(uid)
        self.uid = uid

        if people_ou_entry.present?
          UcbRailsUser::UserLdapService.create_or_update_user_from_entry(people_ou_entry).tap do |user|
            if missing_or_invalid_email?(user)
              user.update(email: people_ou_entry.alternate_email) if people_ou_entry.alternate_email.present?
            end
            user.touch(:last_login_at)
          end
        else
          nil
        end
      end

      private

      def missing_or_invalid_email?(user)
        user&.email.blank? || (user.email =~ URI::MailTo::EMAIL_REGEXP).nil?
      end

    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ucb_rails_user-7.0.0 app/models/ucb_rails_user/user_session_manager/in_people_ou_add_to_users_table.rb
ucb_rails_user-6.2.2 app/models/ucb_rails_user/user_session_manager/in_people_ou_add_to_users_table.rb
ucb_rails_user-6.2.0 app/models/ucb_rails_user/user_session_manager/in_people_ou_add_to_users_table.rb
ucb_rails_user-6.1.1 app/models/ucb_rails_user/user_session_manager/in_people_ou_add_to_users_table.rb
ucb_rails_user-6.1.0 app/models/ucb_rails_user/user_session_manager/in_people_ou_add_to_users_table.rb
ucb_rails_user-6.0.0 app/models/ucb_rails_user/user_session_manager/in_people_ou_add_to_users_table.rb
ucb_rails_user-5.0.0 app/models/ucb_rails_user/user_session_manager/in_people_ou_add_to_users_table.rb
ucb_rails_user-4.1.2 app/models/ucb_rails_user/user_session_manager/in_people_ou_add_to_users_table.rb