From 9d61659604e3351643c2b5746773ed0c5b32bc04 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 16 Jun 2020 09:31:55 -0400 Subject: [PATCH] Updated store_location_for for redirecting after sign in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Updated: - store_location_for for redirecting after sign in --- app/controllers/application_controller.rb | 2 +- app/controllers/auth/sessions_controller.rb | 8 +++++++- app/controllers/manifests_controller.rb | 2 ++ app/controllers/media_controller.rb | 2 ++ app/controllers/media_proxy_controller.rb | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e338b3c7..5b8c6347 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -37,7 +37,7 @@ class ApplicationController < ActionController::Base end def store_current_location - store_location_for(:user, request.url) unless request.format == :json + store_location_for(:user, request.url) if request.format == :html end def require_admin! diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index df991056..72bd4ff1 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -52,7 +52,13 @@ class Auth::SessionsController < Devise::SessionsController end def after_sign_in_path_for(resource) - return '/home' + last_url = stored_location_for(:user) + + if home_paths(resource).include?(last_url) + root_path + else + last_url || root_path + end end def after_sign_out_path_for(_resource_or_scope) diff --git a/app/controllers/manifests_controller.rb b/app/controllers/manifests_controller.rb index ac267c22..332d845d 100644 --- a/app/controllers/manifests_controller.rb +++ b/app/controllers/manifests_controller.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class ManifestsController < ApplicationController + skip_before_action :store_current_location + def show render json: InstancePresenter.new, serializer: ManifestSerializer end diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index ee423124..86a7d3e0 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -3,6 +3,8 @@ class MediaController < ApplicationController include Authorization + skip_before_action :store_current_location + before_action :set_media_attachment before_action :verify_permitted_status! diff --git a/app/controllers/media_proxy_controller.rb b/app/controllers/media_proxy_controller.rb index 36b58c8d..ef5574d3 100644 --- a/app/controllers/media_proxy_controller.rb +++ b/app/controllers/media_proxy_controller.rb @@ -3,6 +3,8 @@ class MediaProxyController < ApplicationController include RoutingHelper + skip_before_action :store_current_location + def show RedisLock.acquire(lock_options) do |lock| if lock.acquired?