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
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])
# 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
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