Reputation: 4005
I'm trying to set up Devise such that any failed auth redirects to the sign up page, with the exception of the sign in page which will redirect to itself. I have the following custom failure class:
class CustomFailure < Devise::FailureApp
def redirect_url
new_user_registration_path
end
def respond
if http_auth?
http_auth
else
redirect
end
end
end
The trouble with that is that even a failed post to sign in redirects to sign up. How can I detect within the redirect_url
function which page the request came from so that I can redirect accordingly?
Upvotes: 0
Views: 697
Reputation: 2720
Try:
redirect_path = "whareveeeeeeer.com"
redirect_to redirect_path
I use it in my DELETE method:
# DELETE /resource/sign_out
def destroy
redirect_path = after_sign_out_path_for(resource_name)
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
yield resource if block_given?
# We actually need to hardcode this as Rails default responder doesn't
# support returning empty response on GET request
respond_to do |format|
format.all { head :no_content }
format.any(*navigational_formats) { redirect_to redirect_path }
end
end
Upvotes: 1