diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-27 17:50:33 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-05-04 14:54:43 +0300 |
commit | 7684217d6806408cd338260119364419260d1720 (patch) | |
tree | 7b913d6c6c051a463d99ad286e2ac04a6b8d5632 /app/controllers/users | |
parent | 10aa55a770c2985c22c92d17b8a7ea90b0a09085 (diff) |
Enforces terms in the web application
This enforces the terms in the web application. These cases are
specced:
- Logging in: When terms are enforced, and a user logs in that has not
accepted the terms, they are presented with the screen. They get
directed to their customized root path afterwards.
- Signing up: After signing up, the first screen the user is presented
with the screen to accept the terms. After they accept they are
directed to the dashboard.
- While a session is active:
- For a GET: The user will be directed to the terms page first,
after they accept the terms, they will be directed to the page
they were going to
- For any other request: They are directed to the terms, after they
accept the terms, they are directed back to the page they came
from to retry the request. Any information entered would be
persisted in localstorage and available on the page.
Diffstat (limited to 'app/controllers/users')
-rw-r--r-- | app/controllers/users/terms_controller.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/app/controllers/users/terms_controller.rb b/app/controllers/users/terms_controller.rb index 32507bdb7b1..95c5c3432d5 100644 --- a/app/controllers/users/terms_controller.rb +++ b/app/controllers/users/terms_controller.rb @@ -1,5 +1,8 @@ module Users class TermsController < ApplicationController + include InternalRedirect + + skip_before_action :enforce_terms! before_action :terms layout 'terms' @@ -46,11 +49,18 @@ module Users end def redirect_path - referer = if request.referer && !request.referer.include?(terms_path) - URI(request.referer).path - end + redirect_to_path = safe_redirect_path(params[:redirect]) || safe_redirect_path_for_url(request.referer) + + if redirect_to_path && + excluded_redirect_paths.none? { |excluded| redirect_to_path.include?(excluded) } + redirect_to_path + else + root_path + end + end - params[:redirect] || referer || root_path + def excluded_redirect_paths + [terms_path, new_user_session_path] end end end |