phatworx/devise_security_extension — Issue #29: PasswordArchivable: Change OldPassword To Order By Id
Author: vizjerai
Created: 2012-02-06 20:42:56+00:00
State: open

I ran into an issue when passwords were changed rapidly (more specifically from tests) and old passwords that should have been removed weren't the correct ones.

I figured out that my tests would require passing the time by 1 second between each change to make sure the expected old_password was removed because the old passwords was ordered by the created_at timestamp. It should be safe to change the order column to the ID because the migration will create the ID column by default and older IDs should have the older passwords.

```self.old_passwords.order('created_at DESC')``` should be changed to ```self.old_passwords.reverse_order(:id)``` on [Line 29](https://github.com/phatworx/devise_security_extension/blob/master/lib/devise_security_extension/models/password_archivable.rb#L29) and [Line 51](https://github.com/phatworx/devise_security_extension/blob/master/lib/devise_security_extension/models/password_archivable.rb#L51)