设计数据库可验证映射到新密码

时间:2018-10-31 12:43:28

标签: ruby-on-rails devise

我在推翻设计策略database_authencatable时,偶然发现了我不了解的事情。那就是:

mapping.to.new.password = password if !hashed && Devise.paranoid

def authenticate!
  resource  = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
  hashed = false
  if validate(resource){ hashed = true; resource.valid_password?(password) }
    remember_me(resource)
    resource.after_database_authentication
    success!(resource)
  end

  mapping.to.new.password = password if !hashed && Devise.paranoid
  unless resource
    Devise.paranoid ? fail(:invalid) : fail(:not_found_in_database)
  end
end

0 个答案:

没有答案