X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/303e5d3eb99284ab4fa41be85f831333f2154b0d..6c2089da2d555d7209ae4d7d25f6e64ac3f6c6f0:/app/controllers/user_controller.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 8fdb89b22..93ca03d66 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -16,21 +16,29 @@ 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 => 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'] + @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || DEFAULT_LEGALE @text = OSM.legal_text_for_country(@legale) if request.xhr? render :update do |page| - page.replace_html "contributorTerms", :partial => "terms" + page.replace_html "contributorTerms", :partial => "terms", :locals => { :has_decline => params[:has_decline] } + end + else + @title = t 'user.terms.title' + @user = User.new(params[:user]) if params[:user] + + if @user + if @user.invalid? + render :action => :new + elsif @user.terms_agreed? + redirect_to :action => :account, :display_name => @user.display_name + end + else + redirect_to :action => :login, :referer => request.request_uri end - elsif @user.invalid? - render :action => 'new' end end @@ -40,7 +48,17 @@ class UserController < ApplicationController 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' + redirect_to t('user.terms.declined') + elsif @user + if !@user.terms_agreed? + @user.consider_pd = params[:user][:consider_pd] + @user.terms_agreed = Time.now.getutc + if @user.save + flash[:notice] = t 'user.new.terms accepted' + end + end + + redirect_to :action => :account, :display_name => @user.display_name else @user = User.new(params[:user]) @@ -148,7 +166,7 @@ class UserController < ApplicationController if params[:user] @user.pass_crypt = params[:user][:pass_crypt] @user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation] - @user.status = "active" + @user.status = "active" if @user.status == "pending" @user.email_valid = true if @user.save @@ -188,7 +206,7 @@ class UserController < ApplicationController # them to that unless they've also got a block on them, in # which case redirect them to the block so they can clear it. if user.blocked_on_view - redirect_to user.blocked_on_view, :referrer => params[:referrer] + redirect_to user.blocked_on_view, :referer => params[:referer] elsif params[:referer] redirect_to params[:referer] else @@ -197,7 +215,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