Преглед на файлове

Add remember me autologin feature

master
Adrian Short преди 11 години
родител
ревизия
184875f13f
променени са 3 файла, в които са добавени 33 реда и са изтрити 13 реда
  1. +11
    -10
      config/initializers/sorcery.rb
  2. +15
    -0
      db/migrate/20130320181527_add_remember_me_token_to_users.rb
  3. +7
    -3
      db/schema.rb

+ 11
- 10
config/initializers/sorcery.rb Целия файл

@@ -27,7 +27,6 @@ Rails.application.config.sorcery.configure do |config|
#
# config.cookie_domain =


# -- session timeout --
# How long in seconds to keep the session alive.
# Default: `3600`
@@ -283,17 +282,8 @@ Rails.application.config.sorcery.configure do |config|
# manually handle how and when email is sent
# Default: `false`
#
# user.reset_password_mailer_disabled =

# reset password email
# method on your mailer
# class.
# Default: `:reset_password_email`
#
# user.reset_password_email_method_name =

# how many seconds before the reset request expires. nil for never expires.
# Default: `nil`
#
@@ -399,6 +389,17 @@ Rails.application.config.sorcery.configure do |config|
# Default: `:uid`
#
# user.provider_uid_attribute_name =

# -- remember_me --
# allow the remember_me cookie to settable through AJAX
# Default: `true`
#
# user.remember_me_httponly =
# How long in seconds the session length will be
# Default: `604800`
#
user.remember_me_for = 60 * 60 * 24 * 7 # 1 week
end

# This line must come after the 'user config' block.


+ 15
- 0
db/migrate/20130320181527_add_remember_me_token_to_users.rb Целия файл

@@ -0,0 +1,15 @@
class AddRememberMeTokenToUsers < ActiveRecord::Migration
def self.up
add_column :users, :remember_me_token, :string, :default => nil
add_column :users, :remember_me_token_expires_at, :datetime, :default => nil

add_index :users, :remember_me_token
end

def self.down
remove_index :users, :remember_me_token

remove_column :users, :remember_me_token_expires_at
remove_column :users, :remember_me_token
end
end

+ 7
- 3
db/schema.rb Целия файл

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20130228150425) do
ActiveRecord::Schema.define(:version => 20130320181527) do

create_table "feeds", :force => true do |t|
t.string "title"
@@ -56,8 +56,12 @@ ActiveRecord::Schema.define(:version => 20130228150425) do
t.string "email"
t.string "crypted_password"
t.string "salt"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "remember_me_token"
t.datetime "remember_me_token_expires_at"
end

add_index "users", ["remember_me_token"], :name => "index_users_on_remember_me_token"

end

Зареждане…
Отказ
Запис