Question on usage
davesag opened this issue · 0 comments
davesag commented
Hi, I was wondering if you could answer this for me.
I want to use bcrypt
to one-way hash my User
passwords.
I've posted a question to StackOverflow regarding this, but figured I'd ask you directly.
Assuming my User is along the lines of your Readme file.
class User
include Mongoid::Document
include Mongoid::Encryptor
field :name
field :password
encrypts :password
end
Could I just write a helper method in my webapp as follows?
def login (name, cleartxtpass)
return User.where(name: name, password: cleartxtpass).first
end
If so is how do I tell it to use bcrypt
? and is there any preprocessing I need to do to cleartxtpass
Cheers
Dave