- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
关于如何记住我与 Omniauth 一起工作似乎有些困惑。
根据这个wiki ,您需要在 OmniauthCallbacksController 中包含以下内容:
remember_me(user)
user.remember_me = true
def remember_me
true
end
# -*- encoding : utf-8 -*-
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
include Devise::Controllers::Rememberable
def all
omniauth = request.env["omniauth.auth"]
auth = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
if auth
auth.update_with_omniauth omniauth
auth.save!
# ???
remember_me auth.user
auth.user.remember_me = true
if user_signed_in?
redirect_back_or settings_path(current_user)
else
sign_in_and_redirect auth.user, event: :authentication
end
else
if user_signed_in?
current_user.build_auth(omniauth).save!
redirect_back_or settings_path(current_user)
else
session["devise.omniauth"] = omniauth.except('extra')
redirect_to new_user_registration_url
end
end
end
alias_method :facebook, :all
alias_method :twitter, :all
end
最佳答案
这是回答 here来自 Jose Valim .
The first option is the correct one. The other two simply set the default value of the field to true, which means it will be automatically remembered whenever the first one is called.
If it works in some browsers or not, it is likely a browser issue because the server is definitely sending the proper cookies. Try to confirm if the cookie is indeed correct and find out if the browser is storing it properly.
关于设计 + Omniauth + remember_me,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25345956/
我正在使用 Symfony 2.3 LTS。 我可以完全使用 Symfony 中的 remember_me 功能,包括设置它和在 session 到期后重新登录。但是我的问题是,一旦用户使用 reme
关于如何记住我与 Omniauth 一起工作似乎有些困惑。 根据这个wiki ,您需要在 OmniauthCallbacksController 中包含以下内容: remember_me(user)
我想存储每个用户登录的时间和日期。 将此代码放入常规登录 View 很简单。 问题出现在 Flask-Login's remember_me已使用-不再调用登录名,这使我无法知道登录名是否新鲜。 我已
要使用 Flask-login 注销 Flask 中的用户,我只需调用 logout_user(),但在添加一些额外的 session 检查后,在我单击注销并再次单击返回“登录页面”后,我仍然登录.
我正在开发一个 Rails 4.2 应用程序并使用 devise gem 进行身份验证。 对于 remember_me 功能,设计生成一个 cookie remember_user_token,它在
我在 SO 上看到过类似的问题,但找不到我的问题的答案。 Symfony2 documentation解释了如何实现记住我的功能。 这是我的parameters.yml: # This file is
我使用 Flask-Login 和 Flask-Principal 开发 Flask 应用程序,到目前为止一切正常,除了 Flask-Login 的记住我功能。 实际上,记住我的功能在 Flask-L
Remember-me是 parameter flask_login.login_user(user, remember=False, duration=None, force=False, fres
我尝试使用 phpcomposer.phar update 更新 symfony2 中的供应商包,但是当我这样做时,我在此行之后收到错误: 更新“app/config/parameters.yml”文
我是一名优秀的程序员,十分优秀!