You're saving the crypted_password and the salt that was used to create
it, so the validation of a newly submitted password is to pass it
through the same function and compare the end results...
Does Bcrypt of "newly submitted password" and u.password_salt ==
u.crypted_password
--
Posted via http://www.ruby-forum.com/.
if BCrypt::Engine.hash_secret(password, u.salt) == u.crypted_password
valid = true
end
I wonder if Authlogic overrode any of the default settings for BCrypt?
What do you get using irb for @version, @cost, @salt, @hash after:
@version, @cost, @salt, @hash = BCrypt::Password.new(u.crypted_password)
on your test user? Source docs indicate Password.new returns a
quadruple:
# File lib/bcrypt.rb, line 161
161: def initialize(raw_hash)
162: if valid_hash?(raw_hash)
163: self.replace(raw_hash)
164: @version, @cost, @salt, @hash = split_hash(self)
165: else
166: raise Errors::InvalidHash.new("invalid hash")
167: end
168: end