Save user password as a bcrypt hash

* Replace password field by password_hash
* Add User#password attribute
* Implement password hashing and verification with BCrypt mixin
This commit is contained in:
Thibault Jouan
2011-08-09 17:04:47 +00:00
parent 0fb9496fb3
commit 1fc3be42de
4 changed files with 58 additions and 5 deletions

View File

@@ -0,0 +1,11 @@
class AddPasswordHashToUsers < ActiveRecord::Migration
def self.up
add_column :users, :password_hash, :string
remove_column :users, :password
end
def self.down
remove_column :users, :password_hash
add_column :users, :password, :string
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110805201426) do
ActiveRecord::Schema.define(:version => 20110809130610) do
create_table "playlists", :force => true do |t|
t.string "name"
@@ -38,9 +38,9 @@ ActiveRecord::Schema.define(:version => 20110805201426) do
create_table "users", :force => true do |t|
t.string "email"
t.string "password"
t.datetime "created_at"
t.datetime "updated_at"
t.string "password_hash"
end
end