I've been trying to figure this out for 2 days. I'm confirming user accounts with email confirmations (via Devise). I finally got all that working, but the whole point was to validate that a person owns the email they claim they own. Therefore, I need to have it confirm again whenever the user changes their email.
In order to do this, I've created registrations_controller and have over written the update method. Mostly based off what Devise has, but I check to see if I need to send confirmation based on the update.
# registrations_controller.rb
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
send_confirmation = false
if params[:user][:email] != resource.email
send_confirmation = true
end
if resource.update_with_password(params[resource_name])
set_flash_message :notice, :updated if is_navigational_format?
sign_in resource_name, resource, :bypass => true
if send_confirmation
resource.update_attributes(:confirmed_at => nil, :confirmation_sent_at => nil)
resource.send_confirmation_instructions
end
respond_with resource, :location => after_update_path_for(resource)
else
clean_up_passwords(resource)
respond_with_navigational(resource){ render_with_scope :edit }
end
end
My problem is I'm not sure where in the process to be able to change where it gets redirected to. I have a page that explains that "an email has been sent in order to confirm your email". But if I try to put it after send_confirmation_instructions when the user clicks "update account" then they are logged out (pushed to the login screen), then when they confirm the account through the email, then they are directed to the page I wanted to show them.
I have a custom Warden Strategy with some puts in it and I also over wrote the before filter that Devise puts in:
# registr