Ruby on Rails +设计+现有用户表==无confirm_tokens

发布于 2024-12-01 05:01:16 字数 270 浏览 1 评论 0原文

我正在创建一个新的轨道系统。我正在设置身份验证设备。我的问题是,我的所有现有用户都没有确认令牌,并且我无法找到向他们获取令牌的方法。我原以为登录时会提示用户重新发送令牌,但事实并非如此。此外,我不知道如何更改身份验证过程以在用户成功身份验证时添加此链接。

我想更改它,以便他们可以在特定时间段内登录,但会在该时间段到期之前向他们显示一个重新发送确认的链接。我看到有一种方法可以设置他们可以登录的时间段,但我不知道该配置在哪里。我还担心,因为他们在数据库中根本没有confirm_token,所以不会有太大作用。

I have a new rails system I am creating. I am in the process of setting up devise for authentication. My issue is that all my existing users do not have confirm tokens, and I can't figure out a way to get the tokens to them. I had expected that upon login the user would be prompted to resend the token but this isn't the case. Furthermore, I can't figure out how to alter the authentication process to add this link when the user successfully authenticates.

I'd like to alter it so they can login for a certain time period but they are presented with a link to resend confirmation before the time period expires. I saw that there is a way to set the time period they are able to login for, but I can't figure out where that configuration is. I'm also concerned that since they don't have a confirm_token at all in the database it won't do much good.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥抱没勇气 2024-12-08 05:01:16

这与设计的可确认选项有关。在这里你必须做两件事。首先,您必须设置允许回答确认的时间段。

要设置用户必须确认的时间段,您必须配置设备初始值设定项并取消注释一行:

# config/initializers/devise.rb
config.confirm_within = 2.days

接下来,您必须手动发送确认邮件(如果不存在,此函数还将创建确认令牌),此可以通过控制台或在脚本中完成:

# in console
User.find(1).send_confirmation_instructions

我会测试它,然后编写以下脚本:

# script.rb
User.all.each do |user|
  user.send_confirmation_instructions
end

如果您有数千个用户但会完成这项工作,那么这是一个非常慢的过程。

看看:可确认

This has to do with the confirmable option of devise. Here you have to do two things. First you have to set the time period that you allow to answer the confirm.

To set the time period that the user has to confirm you have to configure the devise initializer and uncomment one line:

# config/initializers/devise.rb
config.confirm_within = 2.days

Next you have to send the confirmation mail manually (this function will also create the confirmation token if it doesn't exist), this can be done by console or in a script:

# in console
User.find(1).send_confirmation_instructions

I would test that and then write the following script:

# script.rb
User.all.each do |user|
  user.send_confirmation_instructions
end

That is a very slow process if you have thousands of users but will do the job.

Check it out: Confirmable

童话 2024-12-08 05:01:16

确认您的现有用户即可。

User.all.each do |user| user.confirm! end

只需在控制台或脚本中

Just confirm your existing users like so

User.all.each do |user| user.confirm! end

in the console or in a script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文