module SyncAttrWithAuth0::Adapters::ActiveRecord
Public Instance Methods
auth0_sync_configuration()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 45 def auth0_sync_configuration @auth0_sync_configuration ||= setup_auth0_sync_configuration end
Private Instance Methods
auth0_app_metadata()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 162 def auth0_app_metadata # TODO: Source this from a separate attribute list. return {} end
auth0_default_password()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 115 def auth0_default_password # Need a9 or something similar to guarantee one letter and one number in the password "#{auth0_new_uuid[0..19]}aA9" end
auth0_email_verified?()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 126 def auth0_email_verified? # Unless we're explicitly told otherwise, don't consider the email verified. return false unless self.respond_to?(auth0_sync_configuration.email_verified_attribute) return self.send(auth0_sync_configuration.email_verified_attribute) end
auth0_new_uuid()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 121 def auth0_new_uuid ::UUIDTools::UUID.random_create().to_s end
auth0_picture()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 74 def auth0_picture public_send auth0_sync_configuration.picture_attribute if respond_to? auth0_sync_configuration.picture_attribute end
auth0_user_email()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 51 def auth0_user_email self.send(auth0_sync_configuration.email_attribute) if self.respond_to?(auth0_sync_configuration.email_attribute) end
auth0_user_family_name()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 88 def auth0_user_family_name self.send(auth0_sync_configuration.family_name_attribute) if self.respond_to?(auth0_sync_configuration.family_name_attribute) end
auth0_user_given_name()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 83 def auth0_user_given_name self.send(auth0_sync_configuration.given_name_attribute) if self.respond_to?(auth0_sync_configuration.given_name_attribute) end
auth0_user_metadata()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 142 def auth0_user_metadata user_metadata = {} non_metadata_keys = [ auth0_sync_configuration.name_attribute, auth0_sync_configuration.family_name_attribute, auth0_sync_configuration.given_name_attribute, auth0_sync_configuration.email_attribute, auth0_sync_configuration.password_attribute, auth0_sync_configuration.email_verified_attribute ] auth0_attributes_to_sync.each do |key| user_metadata[key.to_s] = self.send(key) if self.respond_to?(key) and non_metadata_keys.index(key).nil? end return user_metadata end
auth0_user_name()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 78 def auth0_user_name self.send(auth0_sync_configuration.name_attribute) if self.respond_to?(auth0_sync_configuration.name_attribute) end
auth0_user_password()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 93 def auth0_user_password self.send(auth0_sync_configuration.password_attribute) if self.respond_to?(auth0_sync_configuration.password_attribute) end
auth0_user_saved_change_to_email?()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 56 def auth0_user_saved_change_to_email? return false unless self.respond_to?(auth0_sync_configuration.email_attribute) # return false unless sync_email_with_auth0? # We don't care if it changed if we aren't syncing it. if respond_to? :"saved_change_to_#{auth0_sync_configuration.email_attribute}?" # Modern method public_send :"saved_change_to_#{auth0_sync_configuration.email_attribute}?" else # Legacy method. Drop when no longer supporting <= Rails 5.1 public_send :"#{auth0_sync_configuration.email_attribute}_changed?" end end
auth0_user_saved_change_to_password?()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 98 def auth0_user_saved_change_to_password? return false unless self.respond_to?(auth0_sync_configuration.password_attribute) case when respond_to?(:"saved_change_to_#{auth0_sync_configuration.password_attribute}?") # Prefer modern method public_send :"saved_change_to_#{auth0_sync_configuration.password_attribute}?" when respond_to?(:"#{auth0_sync_configuration.password_attribute}_changed?") # Legacy method. Drop when no longer supporting <= Rails 5.1 public_send :"#{auth0_sync_configuration.password_attribute}_changed?" else # Neither exists so must be in-memory accessor. Just check if set. public_send(auth0_sync_configuration.password_attribute).present? end end
auth0_user_uid()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 70 def auth0_user_uid self.send(auth0_sync_configuration.auth0_uid_attribute) if self.respond_to?(auth0_sync_configuration.auth0_uid_attribute) end
auth0_verify_password?()
click to toggle source
# File lib/sync_attr_with_auth0/adapters/active_record.rb, line 134 def auth0_verify_password? # Unless we're explicitly told otherwise, verify the password changes. return true unless self.respond_to?(auth0_sync_configuration.verify_password_attribute) self.send(auth0_sync_configuration.verify_password_attribute) end