mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 08:46:41 +01:00
Merge pull request #97 from projekteuler/devise-persistent
Fix persistent devise login
This commit is contained in:
commit
5a7c7d66a9
@ -4,6 +4,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
def sign_in_with(provider_name)
|
||||
@user = User.from_omniauth(request.env["omniauth.auth"])
|
||||
@user.remember_me!
|
||||
@user.remember_me = true
|
||||
sign_in_and_redirect @user, event: :authentication
|
||||
set_flash_message(:notice, :success, kind: provider_name) if is_navigational_format?
|
||||
end
|
||||
|
||||
@ -126,17 +126,17 @@ Devise.setup do |config|
|
||||
|
||||
# ==> Configuration for :rememberable
|
||||
# The time the user will be remembered without asking for credentials again.
|
||||
# config.remember_for = 2.weeks
|
||||
config.remember_for = 2.weeks
|
||||
|
||||
# Invalidates all the remember me tokens when the user signs out.
|
||||
config.expire_all_remember_me_on_sign_out = true
|
||||
|
||||
# If true, extends the user's remember period when remembered via cookie.
|
||||
# config.extend_remember_period = false
|
||||
config.extend_remember_period = true
|
||||
|
||||
# Options to be passed to the created cookie. For instance, you can set
|
||||
# secure: true in order to force SSL only cookies.
|
||||
# config.rememberable_options = {}
|
||||
config.rememberable_options = { secure: Rails.env.production? }
|
||||
|
||||
# ==> Configuration for :validatable
|
||||
# Range for password length.
|
||||
|
||||
5
db/migrate/20190828084343_add_remember_token_to_users.rb
Normal file
5
db/migrate/20190828084343_add_remember_token_to_users.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddRememberTokenToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :remember_token, :string
|
||||
end
|
||||
end
|
||||
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_02_04_164033) do
|
||||
ActiveRecord::Schema.define(version: 2019_08_28_084343) do
|
||||
|
||||
create_table "problems", force: :cascade do |t|
|
||||
t.datetime "created_at"
|
||||
@ -39,6 +39,7 @@ ActiveRecord::Schema.define(version: 2019_02_04_164033) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "name"
|
||||
t.string "remember_token"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user