Consider redirecting to a custom URL if it isnโ€™t verified instead of a flash notification

Implemented using a custom failure class to determine what is the trigger for detection if the user is not authenticated? warden_message does not work. Somebody 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 
+4
source share
1 answer

If you want to redirect users to your own URL, you should do this in redirect_url , and not in respond :

 def redirect_url if warden_message == :unconfirmed '/confirm' else new_user_registration_path end end 
+7
source

Source: https://habr.com/ru/post/1483591/


All Articles