]> cat aescling's git repositories - mastodon.git/commitdiff
Redirect after sign in to previous page (unless it's a sign in/up/etc page)
authorEugen Rochko <eugen@zeonfederated.com>
Sun, 2 Oct 2016 15:11:08 +0000 (17:11 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 2 Oct 2016 15:11:08 +0000 (17:11 +0200)
app/controllers/application_controller.rb
app/controllers/auth/sessions_controller.rb

index 9b6367187d73e91510aad50ed485c09cf74d93a3..91904ecf070f6f8b842e1d0a1c3f50fbe31bfdad 100644 (file)
@@ -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
index 1418ab2ca5b03a6bb9c872bcfc6a91d498ea2e2a..e50a9835c881d8a8211fcc6ef69297f20b55c429 100644 (file)
@@ -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