2
雖然這不是CouchDB特定的,但我正在使用的庫是,它是。我在Ruby中使用couchrest_model創建User
模型像這樣如下:如何使用CouchRest和BCrypt將密碼存儲在CouchDB中?
class User < CouchRest::Model::Base
use_database 'sample'
property :_id, String
property :email, String
# property :password
timestamps!
end
我很困惑與存儲在這裏的密碼。我想使用BCrypt但是當我做這樣的事情:
class User < CouchRest::Model::Base
include BCrypt
use_database 'sample'
property :_id, String
property :email, String
property :password, BCryptHash
timestamps!
end
我得到告訴User::BCryptHash
是一個未初始化的常數。我當然需要預先bcrypt
庫。你能幫我解決BCrypt問題,或者提出一種在CouchDB中存儲密碼的不同方式嗎?我已經看過hashing passwords但是我不知道如何實現這一點。