diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6138fa31..4285682e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -21,20 +21,6 @@ class ApplicationController < ActionController::Base helper_method :authenticated? helper_method :admin? - def after_sign_in_path_for(resource) - sign_in_url = new_user_session_url - sign_up_url = new_user_registration_url - stored = stored_location_for(User) - - if stored - stored - elsif request.referer.include?(sign_in_url) || request.referer.include?(sign_up_url) - super - else - request.referer || root_path - end - end - def handle_unauthorized if authenticated? and params[:controller] == 'maps' and params[:action] == 'show' redirect_to request_access_map_path(params[:id]) @@ -42,7 +28,7 @@ class ApplicationController < ActionController::Base redirect_to root_path, notice: "You don't have permission to see that page." else store_location_for(resource, request.fullpath) - redirect_to new_user_session_path, notice: 'Try signing in to do that.' + redirect_to sign_in_path, notice: 'Try signing in to do that.' end end @@ -60,7 +46,7 @@ class ApplicationController < ActionController::Base def require_user return true if authenticated? - redirect_to new_user_session_path, notice: 'You must be logged in.' + redirect_to sign_in_path, notice: 'You must be logged in.' return false end diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index bffe3ab6..8a66e820 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -7,6 +7,6 @@ class Users::PasswordsController < Devise::PasswordsController end def after_sending_reset_password_instructions_path_for(_resource_name) - new_user_session_path if is_navigational_format? + sign_in_path if is_navigational_format? end end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index e472152e..7c211f26 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -10,6 +10,18 @@ class Users::RegistrationsController < Devise::RegistrationsController signed_in_root_path(resource) end + def after_sign_in_path_for(resource) + stored = stored_location_for(User) + return stored if stored + + if request.referer&.match(sign_in_url) || request.referer&.match(sign_up_url) + super + else + request.referer || root_path + end + end + + private def store_location diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb new file mode 100644 index 00000000..d2daa38c --- /dev/null +++ b/app/controllers/users/sessions_controller.rb @@ -0,0 +1,2 @@ +class Users::SessionsController < Devise::SessionsController +end diff --git a/app/views/layouts/_mobilemenu.html.erb b/app/views/layouts/_mobilemenu.html.erb index f04f79a7..e012a808 100644 --- a/app/views/layouts/_mobilemenu.html.erb +++ b/app/views/layouts/_mobilemenu.html.erb @@ -42,7 +42,7 @@ <%= link_to "Request Invite", request_path %>