From 87e7f887f5da0c38b110425c9bf97b03ce728724 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 16 Jan 2025 18:54:55 +0300 Subject: [PATCH] Remove account terms code unreachable for unregistered users --- app/abilities/ability.rb | 4 +-- app/controllers/accounts/terms_controller.rb | 30 ++++++-------------- config/locales/en.yml | 4 +-- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index 9516a3012..05f4952ac 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -24,13 +24,12 @@ class Ability can [:create, :destroy], :session can [:read, :data, :georss], Trace can [:read, :create, :suspended, :auth_success, :auth_failure], User - can [:read, :update], :account_terms can :read, UserBlock end if user&.active? can :welcome, :site - can :read, :deletion + can :read, [:deletion, :account_terms] if Settings.status != "database_offline" can [:subscribe, :unsubscribe], Changeset @@ -38,6 +37,7 @@ class Ability can [:read, :destroy], :oauth2_authorized_application can [:read, :create, :destroy], :oauth2_authorization can [:update, :destroy], :account + can :update, :account_terms can :read, :dashboard can [:create, :subscribe, :unsubscribe], DiaryEntry can :update, DiaryEntry, :user => user diff --git a/app/controllers/accounts/terms_controller.rb b/app/controllers/accounts/terms_controller.rb index 0513a031c..45e0cc239 100644 --- a/app/controllers/accounts/terms_controller.rb +++ b/app/controllers/accounts/terms_controller.rb @@ -20,46 +20,32 @@ module Accounts else @title = t ".title" - if current_user&.terms_agreed? + if current_user.terms_agreed? # Already agreed to terms, so just show settings redirect_to edit_account_path - elsif current_user.nil? - redirect_to login_path(:referer => request.fullpath) end end end def update - @title = t "users.new.title" - if params[:decline] || !(params[:read_tou] && params[:read_ct]) - if current_user - current_user.terms_seen = true - - flash[:notice] = { :partial => "accounts/terms/terms_declined_flash" } if current_user.save - - referer = safe_referer(params[:referer]) if params[:referer] + current_user.terms_seen = true - redirect_to referer || edit_account_path - elsif params[:decline] - redirect_to t("users.terms.declined"), :allow_other_host => true - else - redirect_to account_terms_path - end - elsif current_user + flash[:notice] = { :partial => "accounts/terms/terms_declined_flash" } if current_user.save + else unless current_user.terms_agreed? current_user.consider_pd = params[:user][:consider_pd] current_user.tou_agreed = Time.now.utc current_user.terms_agreed = Time.now.utc current_user.terms_seen = true - flash[:notice] = t "users.new.terms accepted" if current_user.save + flash[:notice] = t ".terms accepted" if current_user.save end + end - referer = safe_referer(params[:referer]) if params[:referer] + referer = safe_referer(params[:referer]) if params[:referer] - redirect_to referer || edit_account_path - end + redirect_to referer || edit_account_path end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index e9b3c15e1..21a7ce0f2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -318,7 +318,6 @@ en: readable_summary: human readable summary informal_translations: informal translations continue: "Continue" - declined: "https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined" cancel: "Cancel" you need to accept or decline: "Please read and then either accept or decline the new Contributor Terms to continue." legale_select: "Country of residence:" @@ -326,6 +325,8 @@ en: france: "France" italy: "Italy" rest_of_world: "Rest of the world" + update: + terms accepted: "Thanks for accepting the new contributor terms!" terms_declined_flash: terms_declined_html: We are sorry that you have decided to not accept the new Contributor Terms. For more information, please see %{terms_declined_link}. terms_declined_link: this wiki page @@ -2772,7 +2773,6 @@ en: contributor_terms_url: "https://osmfoundation.org/wiki/Licence/Contributor_Terms" contributor_terms: "contributor terms" continue: Sign Up - terms accepted: "Thanks for accepting the new contributor terms!" email_help: privacy_policy: privacy policy privacy_policy_url: https://osmfoundation.org/wiki/Privacy_Policy -- 2.39.5