【问题标题】:How to remove devise password resetting during email confirmation?如何在电子邮件确认期间删除设备密码重置?
【发布时间】:2013-07-14 09:55:08
【问题描述】:

我的电子邮件确认适用于设计,但我想删除此自动密码重置。我无法找到在哪个文件中设计命令此操作。提前谢谢你!

【问题讨论】:

  • 又是什么问题?
  • 你的意思是Forgot your password? 功能吗?
  • 我好像没写清楚,不好意思。当我点击我的电子邮件确认链接时,它会自动重置帐户密码,而我不想这样做。
  • 现在好了!我认为这是因为设计,但问题是 Michael Hartl 的教程中使用的加密!我在这里找到了解决方案:stackoverflow.com/questions/5463153/…

标签: ruby-on-rails ruby email devise confirmation


【解决方案1】:

假设你的设计模型是User:

  1. 删除app/models/user.rb 中的:recoverable 模块
  2. 如果您曾经生成过设计视图,请删除 app/views/devise/shared/_links.html.erb 中的 Forgot your password? 链接
  3. 创建一个迁移删除 reset_password_token 和 reset_password_sent_at 的 users 表:

第一次运行:

rails g migration RemoveRecoverableFromUsers

编辑迁移:

class RemoveRecoverableFromUsers < ActiveRecord::Migration[5.0]
  def up
    remove_column :users, :reset_password_token
    remove_column :users, :reset_password_sent_at
  end

  def down
    add_column :users, :reset_password_token, :string
    add_column :users, :reset_password_sent_at, :datetime
  end
end

【讨论】:

    【解决方案2】:

    如果您不想在 Devise 中提供密码恢复功能,则不应在模型中设置设计属性 ':recoverable'。请从您的模型中删除此属性,从您的视图中删除忘记密码的链接,您将无法再使用 Devise 重置密码。

    【讨论】:

      【解决方案3】:

      只需禁用 User 模型中的 :recoverable 模块并删除 忘记密码? devise/sessions/new.html.erb 中的链接

      【讨论】:

      • 看来你只需要删除 :recoverable 并且链接不会被渲染
      猜你喜欢
      • 2013-06-12
      • 1970-01-01
      • 2017-02-22
      • 1970-01-01
      • 2018-11-02
      • 2013-07-11
      • 1970-01-01
      • 2012-03-09
      • 2016-03-20
      相关资源
      最近更新 更多