Skip to content

Instantly share code, notes, and snippets.

@danmayer
Created April 21, 2015 02:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danmayer/f66782e13bd8c327a9fe to your computer and use it in GitHub Desktop.
Save danmayer/f66782e13bd8c327a9fe to your computer and use it in GitHub Desktop.
setting devise passwords on users from parse and proving it works
user_pass = "password1"
User.where(:email => 'danmayer@gmail.com').first.update(password: user_pass, password_confirmation: user_pass)
resource = User.find_by_email("danmayer@gmail.com")
bcrypt = BCrypt::Password.new(resource.encrypted_password)
password = BCrypt::Engine.hash_secret("#{user_pass}", bcrypt.salt)
valid = Devise.secure_compare(password, resource.encrypted_password)
#true
#this is from the dev parse export
user.update_column(:encrypted_password, '$2a$10$omjZSdTno/pRfPgHcDy2YOA55fTaQQkzRp7ikBmsXc5tiBGwGynzy')
resource = User.find_by_email("danmayer@gmail.com")
bcrypt = BCrypt::Password.new(resource.encrypted_password)
password = BCrypt::Engine.hash_secret("#{user_pass}", bcrypt.salt)
valid = Devise.secure_compare(password, resource.encrypted_password)
#true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment