Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 注册后如何在未确认链接的情况下登录_Ruby On Rails_Ruby_Devise - Fatal编程技术网

Ruby on rails 注册后如何在未确认链接的情况下登录

Ruby on rails 注册后如何在未确认链接的情况下登录,ruby-on-rails,ruby,devise,Ruby On Rails,Ruby,Devise,我在我的用户模型中使用design:confirmatible 我的要求是,注册/注册后,用户应成功登录(无需确认),并将确认链接发送到用户的电子邮件 第二次,若用户未确认其帐户,则不应登录 如何实现这一目标 谢谢要实现您想要的目标,您需要创造一些魔法来覆盖设计和功能。如果您选择沿着这条路走下去,那么页面上有许多重写designe控制器的示例。通过启用:trackable模块,您将可以访问sign\u in\u count,您可以使用该模块检查并只允许一个,直到确认为止 然而,我想提供一个更简单

我在我的用户模型中使用design:confirmatible

我的要求是,注册/注册后,用户应成功登录(无需确认),并将确认链接发送到用户的电子邮件

第二次,若用户未确认其帐户,则不应登录

如何实现这一目标

谢谢

要实现您想要的目标,您需要创造一些魔法来覆盖设计和功能。如果您选择沿着这条路走下去,那么页面上有许多重写designe控制器的示例。通过启用
:trackable
模块,您将可以访问
sign\u in\u count
,您可以使用该模块检查并只允许一个,直到确认为止

然而,我想提供一个更简单的解决方案,你可能会觉得可以接受。如果从第122行开始查看
designe.rb
文件,您将看到您可以在一段时间内允许对应用程序进行未经确认的访问

# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming his account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming his account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming his account.
# config.allow_unconfirmed_access_for = 2.days

我认为,从开发人员和最终用户的角度来看,最终启用此功能并将其设置为应用程序可以接受的方式将是更好的方法。我还将确保在第34行中添加一些内容,以便在用户必须通过电子邮件确认其帐户之前,
send\u instructions
通知用户他们有x个小时/天的时间使用视力。

最简单的方法是您指示
config.allow\u unconfirmed\u access\u=2.分钟
注册后,他将登录,但两分钟后,他将无法登录,除非他在两分钟内注销并登录。

回答太棒了。谢谢+1有什么窍门可以让它发挥作用吗?我取消了该行的注释,但在尝试通过API登录时,它似乎不起作用。