Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

devise redirect to a custom url when not confirmed instead of flash notice

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
like image 455
Rubytastic Avatar asked May 30 '13 13:05

Rubytastic


1 Answers

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
like image 159
Old Pro Avatar answered Oct 06 '22 02:10

Old Pro