trace = Trace.find(params[:id])
if trace.visible? and (trace.public? or (@user and @user == trace.user))
- if Acl.address(request.remote_ip).where(:k => "no_trace_download").exists?
+ if Acl.match(request.remote_ip).where(:k => "no_trace_download").exists?
render :nothing => true, :status => :forbidden
elsif request.format == Mime::XML
send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => Mime::XML.to_s, :disposition => 'attachment')
else
render :action => 'terms'
end
+ elsif Acl.match(request.remote_ip, params[:user][:email].split("@").last).where(:k => "no_account_creation").exists?
+ render :action => 'blocked'
else
session[:referer] = params[:referer]
def save
@title = t 'user.new.title'
- if Acl.address(request.remote_ip).where(:k => "no_account_creation").exists?
- render :action => 'new'
- elsif params[:decline]
+ if params[:decline]
if @user
@user.terms_seen = true
else
redirect_to :action => :account, :display_name => @user.display_name
end
+ elsif Acl.match(request.remote_ip, params[:user][:email].split("@").last).where(:k => "no_account_creation").exists?
+ render :action => 'blocked'
else
@user = User.new(params[:user])
:openid_url => params[:openid])
flash.now[:notice] = t 'user.new.openid association'
+ elsif Acl.match(request.remote_ip).where(:k => "no_account_creation").exists?
+ render :action => 'blocked'
end
end
class Acl < ActiveRecord::Base
- scope :address, lambda { |address| where("address >> ?", address) }
+ def self.match(address, domain = nil)
+ if domain
+ condition = Acl.where("address >> ? OR domain = ?", address, domain)
+ else
+ condition = Acl.where("address >> ?", address)
+ end
+ end
end
--- /dev/null
+<h1><%= t 'user.new.heading' %></h1>
+
+<p><%= t 'user.new.no_auto_account_create' %></p>
+
+<p><%= t 'user.new.contact_webmaster' %></p>
<h1><%= t 'user.new.heading' %></h1>
-<% if Acl.address(request.remote_ip).where(:k => "no_account_creation").exists? %>
-
-<p><%= t 'user.new.no_auto_account_create' %></p>
-
-<p><%= t 'user.new.contact_webmaster' %></p>
-
-<% else %>
-
<p><%= t 'user.new.fill_form' %></p>
<%= error_messages_for 'user' %>
disableOpenID();
<% end -%>
</script>
-
-<% end %>
--- /dev/null
+class AddDomainToAcl < ActiveRecord::Migration
+ def up
+ add_column :acls, :domain, :string
+ change_column :acls, :address, :inet, :null => true
+ end
+
+ def down
+ change_column :acls, :address, :inet, :null => false
+ remove_column :acls, :domain
+ end
+end