-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration legacy database hack - stopped working? #1858
Comments
What is the legacy database hack? |
Btw, were you running on Devise 2.0.4 without deprecations warnings? |
I'm following this How To: Migration legacy database to migrate from clearance to Devise, the only change is sha1 instead of MD5. Yes it is working fine with 2.0.4 without deprecations warnings. |
Looking at the wiki, i can't see any reason for that to stop working. Are |
It doesn't work. I'm using pry for debugging and tried to binding.pry inside def valid_password_with_legacy?(password)
binding.pry
.
.
end But it's not called during authentication process. |
I have updated the gist to use DatabaseAuthenticatable.class_eval, can you |
Thanks Josevalim, Issue is resolved. class_eval helped in debugging the issue. My mistake I enabled config.pepper which triggered failed logins, and then enable encryptable which stooped executing this legacy support code. Please accept my apologies for taking your valuable time, and thank you very much for helping me out. |
@shanlalit now that you got it working, i would like to propose a better solution. Instead of using alias_method_chain, why don't you simply override it in your model and call super instead? class User
def valid_password_with_legacy?(password)
if self.legacy_password_hash.present?
if ::Digest::MD5.hexdigest(password).upcase == self.legacy_password_hash
self.password = password
self.legacy_password_hash = nil
self.save!
true
else
false
end
else
super
end
end
def reset_password!(*args)
self.legacy_password_hash = nil
super
end
end Can you try a solution along these lines and update the wiki if it works for you? Thanks! (closing this) |
I'm using Rails 3.1.4 on REE 1.8.7, updated from 2.0.4 to 2.1, now the legacy hack has stopped working.
In 2.0.4 it was working fine, in 2.1 it returning 401, do I need change anything?
The text was updated successfully, but these errors were encountered: