class Identity < OmniAuth::Identity::Models::ActiveRecord
auth_key :email
attr_accessor :old_password
MAX_LOGIN_ATTEMPTS = 5
validates :email, uniqueness: true, email: true, presence: true unless :phone_number?
validates :phone_number, uniqueness: true, numericality: true, presence: true unless :email?
validates :password, presence: true, length: { minimum: 6, maximum: 64 }
validates :password_confirmation, presence: true, length: { minimum: 6, maximum: 64 }
before_validation :sanitize
def increment_retry_count
self.retry_count = (retry_count || 0) + 1
end
def too_many_failed_login_attempts
retry_count.present? && retry_count >= MAX_LOGIN_ATTEMPTS
end
private
def sanitize
self.email.try(:downcase!)
end
end
我怎么改都是只能手机登陆或者只能邮箱登陆。怎么能实现都可以登录呢。