update authentication system to Devise

This commit is contained in:
Lee Lawlor
2014-03-13 19:16:35 -04:00
parent 4c9886612f
commit 774543e678
78 changed files with 1257 additions and 385 deletions

View File

@ -0,0 +1,35 @@
class AddDeviseToUsers < ActiveRecord::Migration
def self.up
change_table(:users) do |t|
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0, :null => false
end
# remove authlogic stuff
remove_column :users, :persistence_token
remove_column :users, :perishable_token
# modify authlogic stuff
rename_column :users, :crypted_password, :encrypted_password
rename_column :users, :current_login_at, :current_sign_in_at
rename_column :users, :last_login_at, :last_sign_in_at
rename_column :users, :current_login_ip, :current_sign_in_ip
rename_column :users, :last_login_ip, :last_sign_in_ip
add_index :users, :reset_password_token, :unique => true
end
def self.down
# By default, we don't want to make any assumption about how to roll back a migration when your
# model already existed. Please edit below which fields you would like to remove in this migration.
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -0,0 +1,6 @@
class RemoveNotnullFromUsersPasswordSalt < ActiveRecord::Migration
def change
change_column :users, :password_salt, :string, :null => true
end
end

View File

@ -0,0 +1,6 @@
class AddAuthenticationTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :authentication_token, :string
add_index :users, :authentication_token
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140203191645) do
ActiveRecord::Schema.define(version: 20140306013304) do
create_table "api_keys", force: true do |t|
t.string "api_key", limit: 16
@ -348,29 +348,33 @@ ActiveRecord::Schema.define(version: 20140203191645) do
add_index "twitter_accounts", ["user_id"], name: "index_twitters_on_user_id", using: :btree
create_table "users", force: true do |t|
t.string "login", null: false
t.string "email", null: false
t.string "crypted_password", null: false
t.string "password_salt", null: false
t.string "persistence_token", null: false
t.string "perishable_token", null: false
t.datetime "current_login_at"
t.datetime "last_login_at"
t.string "current_login_ip"
t.string "last_login_ip"
t.string "login", null: false
t.string "email", null: false
t.string "encrypted_password", null: false
t.string "password_salt"
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "time_zone"
t.boolean "public_flag", default: false
t.boolean "public_flag", default: false
t.text "bio"
t.string "website"
t.string "api_key", limit: 16
t.string "api_key", limit: 16
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.string "authentication_token"
end
add_index "users", ["api_key"], name: "index_users_on_api_key", using: :btree
add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", using: :btree
add_index "users", ["email"], name: "index_users_on_email", using: :btree
add_index "users", ["login"], name: "index_users_on_login", using: :btree
add_index "users", ["persistence_token"], name: "index_users_on_persistence_token", using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
create_table "watchings", force: true do |t|
t.integer "user_id"