eri*_*cvg 12 devise ruby-on-rails-3 devise-confirmable
我们有一个现有的用户群,并正在添加电子邮件确认.确认是可选的,但允许其他功能.用户无需确认.我添加了可确认模块并运行了迁移.确认按照广告宣传.
但是,用户无法登录,因为他们没有得到确认.所有当前用户都有零确认值,这是我们想要的(用户可以随时返回并确认他们的电子邮件).我已经关注了所有Devise wiki文章并在初始化程序中设置了allow_unconfirmed_access_for:
config.allow_unconfirmed_access_for = 10.years
Run Code Online (Sandbox Code Playgroud)
我也尝试在我们的用户模型中设置它:
devise :confirmable, allow_unconfirmed_access_for: 10.years
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用其他值(1.5年,500天等)
我的SessionsController,与Devise的方法没有太大区别(这里是github)
class Users::SessionsController < Devise::SessionsController
respond_to :json
def new
redirect_to "/#login"
end
def create
resource = warden.authenticate(auth_options)
if !resource
render json: {error: "Invalid email or password" }, status: 401 and return
end
sign_in(resource_name, resource)
render "sign_in", formats: [:json], locals: { object: resource }
end
end
Run Code Online (Sandbox Code Playgroud)
设计的回应:
{"error":"您必须在继续之前确认自己的帐户."}
使用Rails 3.2.9设计2.1.2.
eri*_*cvg 17
我只需要在我的用户模型中执行此操作,而不是使用allow_unconfirmed_access_for:
protected
def confirmation_required?
false
end
Run Code Online (Sandbox Code Playgroud)
hla*_*les 17
Devise团队发布了一个版本(2.2.4),它支持nil作为allow_unconfirmed_access_for的有效值,这意味着没有限制.问题:https://github.com/plataformatec/devise/issues/2275
你现在可以这样做:
config.allow_unconfirmed_access_for = nil
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5699 次 |
| 最近记录: |