def save
@title = 'create account'
- @user = User.new(params[:user])
- @user.visible = true
- @user.data_public = true
- @user.description = "" if @user.description.nil?
- @user.creation_ip = request.remote_ip
-
- if @user.save
- flash[:notice] = "User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)<br>Please note that you won't be able to login until you've received and confirmed your email address."
- Notifier.deliver_signup_confirm(@user, @user.tokens.create)
- redirect_to :action => 'login'
- else
+ if Acl.find_by_address(request.remote_ip, :conditions => {:k => "no_account_creation"})
render :action => 'new'
+ else
+ @user = User.new(params[:user])
+
+ @user.visible = true
+ @user.data_public = true
+ @user.description = "" if @user.description.nil?
+ @user.creation_ip = request.remote_ip
+
+ if @user.save
+ flash[:notice] = "User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)<br>Please note that you won't be able to login until you've received and confirmed your email address."
+ Notifier.deliver_signup_confirm(@user, @user.tokens.create)
+ redirect_to :action => 'login'
+ else
+ render :action => 'new'
+ end
end
end
--- /dev/null
+class Acl < ActiveRecord::Base
+ def self.find_by_address(address, options)
+ self.with_scope(:find => {:conditions => ["inet_aton(?) & netmask = address", address]}) do
+ return self.find(:first, options)
+ end
+ end
+
+ def self.find_all_by_address(address, options)
+ self.with_scope(:find => {:conditions => ["inet_aton(?) & netmask = address", address]}) do
+ return self.find(:all, options)
+ end
+ end
+end
-<h1>Create a user account</h1><br>
-Fill in the form and we'll send you a quick email to activate your account.<br><br>
+<h1>Create a user account</h1>
-By creating an account, you agree that all work uploaded to openstreetmap.org and all data created by use of any tools which connect to openstreetmap.org is to be (non-exclusively) licensed under <a href="http://creativecommons.org/licenses/by-sa/2.0/">this Creative Commons license (by-sa)</a>.<br><br>
+<% if Acl.find_by_address(request.remote_ip, :conditions => {:k => "no_account_creation"}) %>
+
+<p>Unfortunately we are not currently able to create an account for
+ you automatically.
+</p>
+
+<p>Please contact the <a href="mailto:webmaster@openstreetmap.org">webmaster</a>
+ to arrange for an account to be created - we will try and deal with
+ the request as quickly as possible.
+</p>
+
+<% else %>
+
+<p>Fill in the form and we'll send you a quick email to activate your
+ account.
+</p>
+
+<p>By creating an account, you agree that all work uploaded to
+ openstreetmap.org and all data created by use of any tools which
+ connect to openstreetmap.org is to be (non-exclusively) licensed under
+ <a href="http://creativecommons.org/licenses/by-sa/2.0/">this Creative
+ Commons license (by-sa)</a>.
+</p>
<%= error_messages_for 'user' %>
<input type="submit" value="Signup">
<% end %>
+
+<% end %>
--- /dev/null
+class CreateAcls < ActiveRecord::Migration
+ def self.up
+ create_table "acls", myisam_table do |t|
+ t.column "id", :integer, :null => false
+ t.column "address", :integer, :null => false
+ t.column "netmask", :integer, :null => false
+ t.column "k", :string, :null => false
+ t.column "v", :string
+ end
+
+ add_primary_key "acls", ["id"]
+ add_index "acls", ["k"], :name => "acls_k_idx"
+
+ change_column "acls", "id", :integer, :null => false, :options => "AUTO_INCREMENT"
+ change_column "acls", "address", :integer, :null => false, :unsigned => true
+ change_column "acls", "netmask", :integer, :null => false, :unsigned => true
+ end
+
+ def self.down
+ drop_table "acls"
+ end
+end
--- /dev/null
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ address: 1
+ netmask: 1
+ k: MyText
+ v: MyText
+
+two:
+ address: 1
+ netmask: 1
+ k: MyText
+ v: MyText
--- /dev/null
+require File.dirname(__FILE__) + '/../test_helper'
+
+class AclTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end