You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In rails console, create a user with password, for example 'secretpass'
Then exit the console;
Start rails console again, user.valid_password?(secretpass) will return false!
Problem Analysis
valid_password?(pass) in lib/sorcey/model.rb don't set stretches to value user specified. The set_encryption_attributes class method will set stretches, authenticate and encrypt will call the set_encryption_attributes class method, but valid_password? don't.
Proposed Solution
call set_encryption_attributes in authenticates_with_sorcery! as below:
module Sorcery
module Model
def authenticates_with_sorcery!
...
::Sorcery::Controller::Config.user_config.tap{|blk| blk.call(@sorcery_config) if blk}
set_encryption_attributes
...
end
end
end
The text was updated successfully, but these errors were encountered:
I wasn't a huge fan of how this overwriting of a singleton config worked, so this will be changed in v1 to no longer be an issue. The config values will live on the instance of the hashing provider instead: sorcery-core/lib/sorcery/config.rb
How to reproduce the bug
change the
config/initializers/sorcery.rb
as below:In rails console, create a user with password, for example 'secretpass'
Then exit the console;
Start rails console again,
user.valid_password?(secretpass)
will return false!Problem Analysis
valid_password?(pass)
inlib/sorcey/model.rb
don't setstretches
to value user specified. Theset_encryption_attributes
class method will setstretches
,authenticate
andencrypt
will call theset_encryption_attributes
class method, butvalid_password?
don't.Proposed Solution
call
set_encryption_attributes
inauthenticates_with_sorcery!
as below:The text was updated successfully, but these errors were encountered: