【问题标题】:Rails: Use a custom URL for password reset with DeviseRails:使用自定义 URL 使用 Devise 重置密码
【发布时间】:2017-10-30 18:18:21
【问题描述】:

我在我的 Rails 应用程序中使用 Devise 进行身份验证。包括重置密码邮件等的密码管理是通过派生自 Devise::PasswordsController 的控制器处理的。比如:

class Users::PasswordsController < Devise::PasswordsController
  def new
    if not set_actionmailer_settings
      error = I18n.t('invalid_paswd_config')
      redirect_to new_user_session_path, 
                  :flash => { :error => error } and return
    end

    super
  end
end

我现在已经迁移到不使用 Rails UI 的新 UI。相反,它调用 Rails API。在发送给用户重置密码的电子邮件中,如果我想使用自定义密码重置 URL,我该怎么做?

【问题讨论】:

    标签: ruby-on-rails ruby devise


    【解决方案1】:

    在您的 routes.rb 中试试这个

    map.devise_for :users, controllers: {passwords: "users/passwords"}, path_names: {
      new: :new
    }
    

    【讨论】:

    • 在哪里指定自定义 URL?我认为这不能回答问题。
    • 自定义 URL 必须有一个 controller 和一个 action,您必须在那里替换它们..
    猜你喜欢
    • 2012-09-23
    • 2011-08-19
    • 2017-03-29
    • 1970-01-01
    • 2018-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多