Files
nairobi/app/controllers/users/sessions_controller.rb
Javi Martín 83e4633643 Don't redirect to POST request URLs after sign out
Sometimes we define URLs for POST requests which are not defined for GET
requests, such as "/residence", so redirecting to it after signing out
results in a routing error.

So instead of using the request referer, we're using the stored location
devise uses, and we're not storing locations in POST requests.
2020-08-11 18:19:48 +02:00

28 lines
659 B
Ruby

class Users::SessionsController < Devise::SessionsController
def destroy
@stored_location = stored_location_for(:user)
super
end
private
def after_sign_in_path_for(resource)
if !verifying_via_email? && resource.show_welcome_screen?
welcome_path
else
super
end
end
def after_sign_out_path_for(resource)
@stored_location.present? && !@stored_location.match("management") ? @stored_location : super
end
def verifying_via_email?
return false if resource.blank?
stored_path = session[stored_location_key_for(resource)] || ""
stored_path[0..5] == "/email"
end
end