diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 719c8abc4..841b32498 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base before_action :ensure_signup_complete before_action :set_locale before_action :track_email_campaign + before_action :set_return_url check_authorization unless: :devise_controller? self.responder = ApplicationResponder @@ -101,4 +102,10 @@ class ApplicationController < ActionController::Base ahoy.track campaign.name if campaign.present? end end + + def set_return_url + if !devise_controller? && controller_name != 'welcome' && is_navigational_format? + store_location_for(:user, request.path) + end + end end diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index d1c1509f1..dac2d7d4b 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -1,15 +1,15 @@ class Users::SessionsController < Devise::SessionsController - def after_sign_in_path_for(resource) - if !verifying_via_email? && resource.show_welcome_screen? - welcome_path - else - super - end - end - private + def after_sign_in_path_for(resource) + if !verifying_via_email? && resource.show_welcome_screen? + welcome_path + else + super + end + end + def verifying_via_email? return false unless resource.present? stored_path = session[stored_location_key_for(resource)] || ""