2 class TermsController < ApplicationController
7 before_action :disable_terms_redirect
8 before_action :authorize_web
9 before_action :set_locale
10 before_action :check_database_readable
12 authorize_resource :class => :account_terms
15 @legale = params[:legale] || OSM.ip_to_country(request.remote_ip) || Settings.default_legale
16 @text = OSM.legal_text_for_country(@legale)
19 render :partial => "terms"
23 if current_user&.terms_agreed?
24 # Already agreed to terms, so just show settings
25 redirect_to edit_account_path
26 elsif current_user.nil?
27 redirect_to login_path(:referer => request.fullpath)
33 @title = t "users.new.title"
35 if params[:decline] || !(params[:read_tou] && params[:read_ct])
37 current_user.terms_seen = true
39 flash[:notice] = { :partial => "accounts/terms/terms_declined_flash" } if current_user.save
41 referer = safe_referer(params[:referer]) if params[:referer]
43 redirect_to referer || edit_account_path
44 elsif params[:decline]
45 redirect_to t("users.terms.declined"), :allow_other_host => true
47 redirect_to account_terms_path
50 unless current_user.terms_agreed?
51 current_user.consider_pd = params[:user][:consider_pd]
52 current_user.tou_agreed = Time.now.utc
53 current_user.terms_agreed = Time.now.utc
54 current_user.terms_seen = true
56 flash[:notice] = t "users.new.terms accepted" if current_user.save
59 referer = safe_referer(params[:referer]) if params[:referer]
61 redirect_to referer || edit_account_path