移动用户在关闭浏览器时正在注销,我想让他们保持登录状态。
我读过这可以通过使用cookies来解决,但我们已经这样做了。
Rails.application.config.session_store :cookie_store, key: '_app_session'
也使用
devise :rememberable
此外,我无法直接在Devise::SessionsController
找到实施Cookie的具体示例。
非常感谢任何帮助。
user.rb
class User < ApplicationRecord
devise :two_factor_authenticatable, :database_authenticatable,
:registerable, :timeoutable, :confirmable, :invitable,
:recoverable, :rememberable, :trackable, :omniauthable,
omniauth_providers: [:linkedin]
has_one_time_password(encrypted: true)
def only_if_unconfirmed
pending_any_confirmation { yield }
end
def timeout_in
setting.custom_timeout.to_i.seconds
end
...
end
我愿意修改设计或更改Rails配置以使其正常工作。
Google搜索结果似乎是默认行为。
根据请求添加 gemfile.rb 。
source 'http://rubygems.org'
ruby '2.4.0'
gem 'comfortable_mexican_sofa'
gem 'exception_notification'
gem 'ransack'
gem 'selectize-rails'
gem 'bitly', '~> 0.10.4'
gem 'yomu', '~> 0.2.4'
gem 'pg'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'kaminari'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jquery-turbolinks'
gem 'jbuilder', '~> 2.5'
gem 'foundation-rails'
gem 'foundation_rails_helper', git: 'https://github.com/sgruhier/foundation_rails_helper'
gem 'inky-rb', require: 'inky'
gem 'premailer-rails'
gem 'redis', '~> 3.0'
gem 'redis-rails', '~> 5'
gem 'resque'
gem 'paper_trail'
gem 'devise'
gem 'omniauth-oauth2', '~> 1.3.1'
gem 'omniauth-linkedin-oauth2'
gem 'omniauth-google-oauth2'
gem 'devise_invitable'
gem 'two_factor_authentication'
gem 'valid_email2'
gem 'geocoder'
gem 'twilio-ruby'
gem 'omnicontacts'
gem 'sparkpost_rails'
gem 'raygun4ruby'
gem 'bonsai-elasticsearch-rails'
gem 'elasticsearch-rails'
gem 'elasticsearch-model'
gem 'searchkick', git: 'https://github.com/ankane/searchkick'
gem 'ahoy_matey'
gem 'blazer'
gem 'subdomain_router'
gem 'figaro'
gem 'paperclip', git: 'https://github.com/thoughtbot/paperclip'
gem 'dropzonejs-rails'
gem 'aws-sdk'
gem 'cocoon', '~> 1.2.9'
gem 'haml-rails', '~> 0.9'
gem 'newrelic_rpm'
gem 'pdf-reader'
gem 'clearbit'
gem 'httparty'
gem 'friendly_id', '~> 5.1.0'
gem "octokit", "~> 4.0"
group :development, :test do
gem 'pry'
gem 'byebug', platform: :mri
gem 'erb2haml'
gem 'haml_lint'
gem "letter_opener"
end
group :development do
gem 'web-console'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'bullet'
gem 'derailed'
end
group :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'heroku-deflater', :group => :production, git: 'https://github.com/romanbsd/heroku-deflater.git'
gem 'chartkick'
gem 'groupdate'
答案 0 :(得分:1)
添加expire_after
Rails.application.config.session_store :cookie_store, key: '_app_session', expire_after: 3.hours