Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## User model
- def self.encrypt_password(password, salt)
- string_to_hash = password + 'e8fa752f318b2bb039a5ded' + salt
- Digest::SHA1.hexdigest(string_to_hash)
- end
- ## User controller
- def new
- @user = User.new(params[:user])
- if request.post? and @user.save
- breakpoint
- #...
- end
- end
- ## Breakpoint commands
- # (Username: michael2)
- # (Password: testpass)
- irb(#<UserController:0x37bbc90>):005:0> @user
- => #<User:0x3798410 @attributes={"created_on"=>Wed Jun 07 14:42:30 Central Standard Time 2006, "salt
- "=>"291476560.761974007124081", "name"=>"michael2", "hashed_password"=>"1a98cd33b9aed292c4735dee69ba
- 72a7ba7f7060", "id"=>8, "email"=>"technel@gmail.com"}, @password_confirmation="testpass", @new_recor
- d=false, @new_record_before_save=true, @errors=#<ActiveRecord::Errors:0x377fb88 @errors={}, @base=#<
- User:0x3798410 ...>>, @password="testpass">
- irb(#<UserController:0x37bbc90>):006:0> @user.name
- => "michael2"
- irb(#<UserController:0x37bbc90>):007:0> @user.password
- => "testpass"
- irb(#<UserController:0x37bbc90>):008:0> @user.hashed_password
- => "1a98cd33b9aed292c4735dee69ba72a7ba7f7060"
- irb(#<UserController:0x37bbc90>):009:0> @user.salt
- => "291476560.761974007124081"
- irb(#<UserController:0x37bbc90>):010:0> User.encrypt_password(@user.password, @user.salt)
- => "605fb78f33d8cb8779dce9848cb68544335e651e"
Add Comment
Please, Sign In to add comment