开发者

Mongoid and has_secure_password

开发者 https://www.devze.com 2023-03-25 01:11 出处:网络
I am trying to use rails 3.1 authentication using mongoid instead of active model class User include Mongoid::Document

I am trying to use rails 3.1 authentication using mongoid instead of active model

 class User 
  include Mongoid::Document
  include ActiveModel::SecurePassword
  has_secure_password  
  validates_presence_of :password, :on => :create
  attr_accessor :email, :password, :password_confirmation 
  field :email, :type => String
  field :password_diges开发者_运维技巧t, :type => String
 end

the problem is password_digest is not recognized by the bycrypt as in active model example http://railscasts.com/episodes/270-authentication-in-rails-3-1

Thanks


For anyone who is interested, the most minimal requirement for using has_secure_password with Mongoid is simply the inclusion of ActiveModel::SecurePassword in the model.

class User
  include Mongoid::Document
  include ActiveModel::SecurePassword

  field :username
  field :password_digest

  has_secure_password
end

Article


Put

has_secure_password

After

field :password_digest, :type => String
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号