From: Eugen Rochko Date: Sun, 2 Oct 2016 15:11:08 +0000 (+0200) Subject: Redirect after sign in to previous page (unless it's a sign in/up/etc page) X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=a0f85774c482716505b0c8c8faf59616f06245d9;p=mastodon.git Redirect after sign in to previous page (unless it's a sign in/up/etc page) --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9b6367187..91904ecf0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,10 +10,18 @@ class ApplicationController < ActionController::Base rescue_from ActionController::RoutingError, with: :not_found rescue_from ActiveRecord::RecordNotFound, with: :not_found + before_filter :store_current_location, :unless => :devise_controller? + def raise_not_found raise ActionController::RoutingError, "No route matches #{params[:unmatched_route]}" end + private + + def store_current_location + store_location_for(:user, request.url) + end + protected def not_found diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 1418ab2ca..e50a9835c 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -12,6 +12,6 @@ class Auth::SessionsController < Devise::SessionsController protected def after_sign_in_path_for(_resource) - root_path + stored_location_for(:user) || root_path end end