password_rehasher

Password Rehasher is a temporary gem to rehash the passwords in the RPM database to scrypt.

Usage

if (PasswordRehasher.password_valid?(plaintext_password, crypted_password)) {
    if (PasswordRehasher.rehash_needed?(crypted_password)) {
        user.crypted_password = PasswordRehasher.hash_password(plaintext_password)
        user.save
    }
    # user is logged in
} else {
    # user is not logged in
}

Alternatively, to do all of the above if user.update_attribute("crypted_password", crypted_password) is what you want to do

if (PasswordRehasher.validate_and_rehash?(user, plaintext_password, crypted_password)) {
    # user is logged in and the password is rehashed (if necessary)
} else {
    # user is not logged in
}