[英]How to redirect to the Devise login page after user requests new confirmation
How would I redirect to the login page after the user has requested a new confirmation email to be received?在用户请求接收新的确认电子邮件后,我将如何重定向到登录页面?
This is not the case where the user logs in for the first time after confirmation like discussed on Stack Overflow.这是不是哪里像堆栈溢出讨论确认后的第一次用户登录的情况。 This is about a non-confirmed, not logged-in user requesting a new confirmation email because they did not receive it.这是关于一个未确认的、未登录的用户请求新的确认电子邮件,因为他们没有收到它。
/users/confirmations/new
.用户转到/users/confirmations/new
。 Instead I want it to go to the login_path
after submit.相反,我希望它在提交后转到login_path
。
I overruled the confirmations controller, but how do I hook into Devise and make it redirect to login_path
?我否决了确认控制器,但是如何连接到 Devise 并使其重定向到login_path
?
class Users::ConfirmationsController < Devise::RegistrationsController
layout :resolve_layout
def new
self.resource = resource_class.new
redirect_to login_path
end
end
You set this path with the following code inside your confirmations_controller
:您可以设置您的内部下面的代码此路径confirmations_controller
:
def after_resending_confirmation_instructions_path_for
login_path # or whatever you want
end
However, the default is to redirect to new_session_path(resource_name)
which does exactly what you want and so it does for my app.但是,默认设置是重定向到new_session_path(resource_name)
,它完全符合您的要求,对我的应用程序也是如此。
Maybe it depends on the version of Devise.也许这取决于设计的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.