【发布时间】:2019-08-30 16:31:45
【问题描述】:
我在应用程序中重置密码时遇到问题。 单击“重置密码”按钮后,我会收到一封电子邮件“重置密码说明”,其中包含指向“重置密码”的链接。
登录时 - 如果我点击电子邮件中的重置密码链接,它会被重定向到根路径,而不是密码重置页面。
注销时 - 从我的应用程序中注销后,然后单击电子邮件中的重置密码链接,它会重定向到编辑密码页面。
密码控制器:
class Users::PasswordsController < Devise::PasswordsController
protected
def after_sending_reset_password_instructions_path_for(resource_name)
edit_user_registration_path
end
end
config/routes.rb:
devise_for :users, controllers: { passwords: 'passwords' }
但仍然得到同样的错误。控制台日志:
Started GET "/users/password/edit?reset_password_token=[FILTERED]" for 127.0.0.1 at 2019-04-09 13:59:26 +0300
Processing by Users::PasswordsController#edit as HTML
Parameters: {"reset_password_token"=>"[FILTERED]"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 10], ["LIMIT", 1]]
↳ /home/anatoly/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/log_subscriber.rb:98
Redirected to http://localhost:3000/
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.3ms)
谁能帮帮我?
提前谢谢你!
【问题讨论】:
-
谢谢!我已经将此功能添加到我的应用程序中。我的问题是关于由管理员重置密码,然后由用户设置新密码。 (正如我的雇主所希望的那样)。我也解决了这个问题。我刚刚将 skip_before_action :require_no_authentication 添加到 PasswordsController.rb。
标签: ruby-on-rails ruby devise