SHARE
TWEET

Untitled

a guest Jul 21st, 2017 444 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # use mongoid
  2. class User
  3.   include Mongoid::Document
  4. end
  5.  
  6.  
  7. # then
  8. user = User.where(email: 'joe@example.com').first
  9.  
  10. if user
  11.   user.password = new_password
  12.   user.password_confirmation = new_password
  13.   user.save
  14. end
  15.    
  16. # $ rails console production
  17. u=User.where(:email => 'usermail@gmail.com').first
  18. u.password='userpassword'
  19. u.password_confirmation='userpassword'
  20. u.save!
  21.    
  22. User.find_by(email: 'user_email_address').reset_password!('new_password','new_password')
  23.    
  24. u = User.find_by_email('user@example.com')
  25. u.update_attribute(:password, '123123')
  26.    
  27. user = User.where(:email => email).first
  28.    
  29. user = User.find_by_email('user@example.com')
  30.    
  31. $ sudo bundle exec rails console production
  32.    
  33. irb(main):001:0> user = User.where("username = 'root'")
  34. irb(main):002:0> u = user.first
  35. irb(main):003:0> u.password="root2014@Robin"
  36. => "root2014@Robin"
  37. irb(main):004:0> u.password_confirmation="root2014@Robin"
  38. => "root2014@Robin"
  39. irb(main):005:0> u.save
  40. => true
  41. irb(main):006:0> exit
  42.    
  43. user.locked_at = ''
  44. user.failed_attempts = '0'
  45. user.save!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top