X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/7e5c998a87ef776276c8015c17cd9e7be79a1692..68368118a63f4d6c2bed18cdf4dce525256b3a41:/app/controllers/user_controller.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 42a50582e..0957853ce 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -16,13 +16,31 @@ class UserController < ApplicationController filter_parameter_logging :password, :pass_crypt, :pass_crypt_confirmation - cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete] + cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete], :unless => OSM_STATUS == :database_offline + + def terms + @title = t 'user.new.title' + @user = User.new(params[:user]) + + @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || APP_CONFIG['default_legale'] + @text = OSM.legal_text_for_country(@legale) + + if request.xhr? + render :update do |page| + page.replace_html "contributorTerms", :partial => "terms" + end + elsif @user.invalid? + render :action => 'new' + end + end def save @title = t 'user.new.title' if Acl.find_by_address(request.remote_ip, :conditions => {:k => "no_account_creation"}) render :action => 'new' + elsif params[:decline] + redirect_to t('user.terms.declined') else @user = User.new(params[:user]) @@ -31,6 +49,7 @@ class UserController < ApplicationController @user.description = "" if @user.description.nil? @user.creation_ip = request.remote_ip @user.languages = request.user_preferred_languages + @user.terms_agreed = Time.now.getutc if @user.save flash[:notice] = t 'user.new.flash create success message' @@ -178,7 +197,8 @@ class UserController < ApplicationController elsif User.authenticate(:username => email_or_display_name, :password => pass, :pending => true) flash.now[:error] = t 'user.login.account not active' elsif User.authenticate(:username => email_or_display_name, :password => pass, :suspended => true) - flash.now[:error] = t 'user.login.account suspended' + webmaster = link_to t('user.login.webmaster'), "mailto:webmaster@openstreetmap.org" + flash.now[:error] = t 'user.login.account suspended', :webmaster => webmaster else flash.now[:error] = t 'user.login.auth failure' end