Pregunta

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.

  • User goes to /users/confirmations/new.
  • submits form.
  • The same form gets shown again.

Instead I want it to go to the login_path after submit.

I overruled the confirmations controller, but how do I hook into Devise and make it redirect to login_path?

class Users::ConfirmationsController < Devise::RegistrationsController

  layout :resolve_layout


  def new
    self.resource = resource_class.new
    redirect_to login_path
  end

end
¿Fue útil?

Solución

You set this path with the following code inside your 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.

Maybe it depends on the version of Devise.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top