1
0
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:
Philipp Fischbeck 2019-08-28 11:41:37 +02:00 committed by GitHub
commit 5a7c7d66a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

View File

@ -4,6 +4,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def sign_in_with(provider_name) def sign_in_with(provider_name)
@user = User.from_omniauth(request.env["omniauth.auth"]) @user = User.from_omniauth(request.env["omniauth.auth"])
@user.remember_me! @user.remember_me!
@user.remember_me = true
sign_in_and_redirect @user, event: :authentication sign_in_and_redirect @user, event: :authentication
set_flash_message(:notice, :success, kind: provider_name) if is_navigational_format? set_flash_message(:notice, :success, kind: provider_name) if is_navigational_format?
end end

View File

@ -126,17 +126,17 @@ Devise.setup do |config|
# ==> Configuration for :rememberable # ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again. # 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. # Invalidates all the remember me tokens when the user signs out.
config.expire_all_remember_me_on_sign_out = true config.expire_all_remember_me_on_sign_out = true
# If true, extends the user's remember period when remembered via cookie. # 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 # Options to be passed to the created cookie. For instance, you can set
# secure: true in order to force SSL only cookies. # secure: true in order to force SSL only cookies.
# config.rememberable_options = {} config.rememberable_options = { secure: Rails.env.production? }
# ==> Configuration for :validatable # ==> Configuration for :validatable
# Range for password length. # Range for password length.

View File

@ -0,0 +1,5 @@
class AddRememberTokenToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :remember_token, :string
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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| create_table "problems", force: :cascade do |t|
t.datetime "created_at" 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 "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "name" t.string "name"
t.string "remember_token"
end end
end end