From 65eb2caeaf1271c66a6b59e67e0d3ce22b1e3455 Mon Sep 17 00:00:00 2001
From: cktricky
Date: Thu, 8 Aug 2013 16:57:58 -0400
Subject: [PATCH] made a suggestion based on digininjas comment on Rails
tutorials blog post. Better to change method name to hash_password than
encrypt_password
---
app/models/user.rb | 4 ++--
.../layouts/tutorial/crypto/_password_hashing.html.erb | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/models/user.rb b/app/models/user.rb
index 8e2b65f..7e92104 100755
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -11,7 +11,7 @@ class User < ActiveRecord::Base
validates_format_of :email, :with => /.+@.+\..+/i
attr_accessor :skip_user_id_assign
before_save :assign_user_id, :on => :create
- before_save :encrypt_password
+ before_save :hash_password
has_one :retirement, :foreign_key => :user_id, :primary_key => :user_id, :dependent => :destroy
has_one :paid_time_off, :foreign_key => :user_id, :primary_key => :user_id, :dependent => :destroy
has_one :work_info, :foreign_key => :user_id, :primary_key => :user_id, :dependent => :destroy
@@ -45,7 +45,7 @@ class User < ActiveRecord::Base
end
end
- def encrypt_password
+ def hash_password
if self.password.present?
self.password = Digest::MD5.hexdigest(password)
end
diff --git a/app/views/layouts/tutorial/crypto/_password_hashing.html.erb b/app/views/layouts/tutorial/crypto/_password_hashing.html.erb
index b6e220e..1a9394e 100755
--- a/app/views/layouts/tutorial/crypto/_password_hashing.html.erb
+++ b/app/views/layouts/tutorial/crypto/_password_hashing.html.erb
@@ -42,7 +42,7 @@
Within app/models/user.rb:
- before_save :encrypt_password
+ before_save :hash_password
def self.authenticate(email, password)
auth = nil
@@ -59,7 +59,7 @@
return auth
end
- def encrypt_password
+ def hash_password
if self.password.present?
self.password = Digest::MD5.hexdigest(password)
end
@@ -98,7 +98,7 @@
end
end
- def encrypt_password
+ def hash_password
if self.password.present?
self.password_salt = BCrypt::Engine.generate_salt
self.password_hash = BCrypt::Engine.hash_secret(self.password, self.password_salt)