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
31 if params[:decline] || !(params[:read_tou] && params[:read_ct])
32 current_user.terms_seen = true
34 flash[:notice] = { :partial => "accounts/terms/terms_declined_flash" } if current_user.save
36 unless current_user.terms_agreed?
37 current_user.consider_pd = params[:user][:consider_pd]
38 current_user.tou_agreed = Time.now.utc
39 current_user.terms_agreed = Time.now.utc
40 current_user.terms_seen = true
42 flash[:notice] = t ".terms accepted" if current_user.save
46 referer = safe_referer(params[:referer]) if params[:referer]
48 redirect_to referer || edit_account_path