5

Implemented with a custom failure class for devise what is the trigger to detect if a user is non confirmed? warden_message does not work. Anyone knows?

class CustomFailure < Devise::FailureApp

  def redirect_url

    if warden_options[:scope] == :user
      new_user_registration_path
    else
      new_user_registration_path
    end
  end

  def respond

    if http_auth?
      http_auth
    else
      store_location!
      flash[:alert] = i18n_message unless flash[:notice]

      if warden_message == :unconfirmed
        redirect_to "/confirm"
      else
        redirect_to sign_in_path
      end
    end

  end

end
Rubytastic
  • 15,001
  • 18
  • 87
  • 175

1 Answers1

8

If you want to redirect users to a custom URL, you should do it in redirect_url, not in respond:

def redirect_url
  if warden_message == :unconfirmed
    '/confirm'
  else
    new_user_registration_path
  end
end
Old Pro
  • 24,624
  • 7
  • 58
  • 106