Module: Decidim::HasStoredPath

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
app/controllers/concerns/decidim/has_stored_path.rb

Overview

Shared behaviour for signed_in users that require the latest TOS accepted

Instance Method Summary collapse

Instance Method Details

#skip_store_location?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/concerns/decidim/has_stored_path.rb', line 26

def skip_store_location?
  # Skip if Devise already handles the redirection
  return true if devise_controller? && redirect_url.blank?
  # Skip for all non-HTML requests"
  return true unless request.format.html?
  # Skip if a signed in user requests the TOS page without having agreed to
  # the TOS. Most of the times this is because of a redirect to the TOS
  # page (in which case the desired location is somewhere else after the
  # TOS is agreed).
  return true if current_user && !current_user.tos_accepted? && request.path == URI(tos_path).path

  false
end

#store_current_locationObject

Stores the url where the user will be redirected after login.

Uses the ‘redirect_url` param or the current url if there is no param. In Devise controllers we only store the URL if it is from the params, we do not want to overwrite the stored URL for a Devise one.



19
20
21
22
23
24
# File 'app/controllers/concerns/decidim/has_stored_path.rb', line 19

def store_current_location
  return if skip_store_location?

  value = redirect_url || request.url
  store_location_for(:user, value)
end