before_filter :require_allow_read_prefs, :only => [:api_details]
before_filter :require_allow_read_gpx, :only => [:api_gpx_files]
before_filter :require_cookies, :only => [:login, :confirm]
- before_filter :require_administrator, :only => [:set_status, :delete]
+ before_filter :require_administrator, :only => [:set_status, :delete, :list]
before_filter :lookup_this_user, :only => [:set_status, :delete]
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])
@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'
set_locale
if @user.new_email.nil? or @user.new_email.empty?
- flash.now[:notice] = t 'user.account.flash update success'
+ flash[:notice] = t 'user.account.flash update success'
else
- flash.now[:notice] = t 'user.account.flash update success confirm needed'
+ flash[:notice] = t 'user.account.flash update success confirm needed'
begin
Notifier.deliver_email_confirm(@user, @user.tokens.create)
# Ignore errors sending email
end
end
+
+ redirect_to :action => "account", :display_name => @user.display_name
end
else
if flash[:errors]
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
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
@this_user.delete
redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]
end
+
+ ##
+ # display a list of users matching specified criteria
+ def list
+ if request.post?
+ ids = params[:user].keys.collect { |id| id.to_i }
+
+ User.update_all("status = 'confirmed'", :id => ids) if params[:confirm]
+ User.update_all("status = 'deleted'", :id => ids) if params[:hide]
+
+ redirect_to url_for(:status => params[:status], :ip => params[:ip], :page => params[:page])
+ else
+ conditions = Hash.new
+ conditions[:status] = params[:status] if params[:status]
+ conditions[:creation_ip] = params[:ip] if params[:ip]
+
+ @user_pages, @users = paginate(:users,
+ :conditions => conditions,
+ :order => :id,
+ :per_page => 50)
+ end
+ end
+
private
+
##
# require that the user is a administrator, or fill out a helpful error message
# and return them to the user page.
def require_administrator
- unless @user.administrator?
+ if @user and not @user.administrator?
flash[:error] = t('user.filter.not_an_administrator')
- redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]
+
+ if params[:display_name]
+ redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]
+ else
+ redirect_to :controller => 'user', :action => 'login', :referer => request.request_uri
+ end
+ elsif not @user
+ redirect_to :controller => 'user', :action => 'login', :referer => request.request_uri
end
end