before_filter :authorize
def create
+ @node = Node.new
+ @node.id = 1
+ @node.latitude = 1
+ @node.save
+ end
+
+ def dummy
if request.post?
userid = dao.useridfromcreds(r.user, r.get_basic_auth_pw)
doc = Document.new $stdin.read
def save
@user = User.new(params[:user])
-# @user.save
- #Notifier::deliver_confirm_signup(user)
+ @user.set_defaults
+
+ if @user.save
+ flash[:notice] = 'Users was successfully created.'
+ Notifier::deliver_signup_confirm(@user)
+ redirect_to :action => 'login'
+ else
+ render :action => 'new'
+ end
+
end
-
+
def new
end
+
+ def confirm
+ @user = User.find_by_token(params[:confirm_string])
+ if @user && @user.active == 0
+ @user.active = true
+ @user.save
+ flash[:notice] = 'Confirmed your account'
+ redirect_to :action => 'login'
+ else
+ flash[:notice] = 'Something went wrong confirming that user'
+ end
+ end
+
end
class Node < ActiveRecord::Base
set_table_name 'current_nodes'
+
belongs_to :user
+
end
class User < ActiveRecord::Base
has_many :traces
- validates_confirmation_of :pass_crypt
+ validates_confirmation_of :pass_crypt, :message => 'Password must match the confirmation password'
+ validates_uniqueness_of :display_name
+ validates_uniqueness_of :email
+ validates_length_of :pass_crypt, :minimum => 8
+ validates_length_of :display_name, :minimum => 3
+ validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
-# def password=(str)
-# write_attribute("pass_crypt", Digest::MD5.hexdigest(str))
-# end
+ def set_defaults
+ self.creation_time = Time.now
+ self.timeout = Time.now
+ self.token = make_token()
+ end
+
+ def pass_crypt=(str)
+ write_attribute("pass_crypt", Digest::MD5.hexdigest(str))
+ end
+ def pass_crypt_confirmation=(str)
+ write_attribute("pass_crypt_confirm", Digest::MD5.hexdigest(str))
+ end
-# def password
-# return self.pass_crypt
-# end
+ def self.authenticate(email, passwd)
+ find_first([ "email = ? AND pass_crypt =?",
+ email,
+ Digest::MD5.hexdigest(passwd) ])
+ end
+
+ private
+ def make_token
+ chars = 'abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
+ confirmstring = ''
+
+ 30.times do
+ confirmstring += chars[(rand * chars.length).to_i].chr
+ end
+
+ return confirmstring
+ end
-# def self.authenticate(username, passwd)
-# find_first([ "display_name = ? AND pass_crypt =?",
-# username,
-# Digest::MD5.hexdigest(passwd) ])
-# end
end
<body>
<div id="content">
+<% if @flash[:notice] %>
+ <div id="notice"><%= @flash[:notice] %></div>
+<% end %>
+
<%= @content_for_layout %>
</div>
By creating an account, you agree that all work uploaded to openstreetmap.org and all data created by use of any tools on openstreetmap.org is to be licensed under <a href="http://creativecommons.org/licenses/by-sa/2.0/">this</a> Creative Commons license.<br><br>
+<%= error_messages_for 'user' %>
+
<%= start_form_tag :action => 'save' %>
<table>
<tr><td>email address:</td><td><%= text_field('user', 'email',{:size => 50, :maxlength => 255}) %></td></tr>
cursor: pointer;\r
}\r
\r
+\r
+/* rails error field stuff */\r
+\r
+.fieldWithErrors {\r
+ padding: 2px;\r
+ background-color: red;\r
+ display: table;\r
+}\r
+\r
+#notice {\r
+ width: 400px;\r
+ border: 2px solid green;\r
+ padding: 7px;\r
+ padding-bottom: 12px;\r
+ margin-bottom: 20px;\r
+ background-color: #f0f0f0;\r
+}\r
+\r
+#errorExplanation {\r
+ width: 400px;\r
+ border: 2px solid red;\r
+ padding: 7px;\r
+ padding-bottom: 12px;\r
+ margin-bottom: 20px;\r
+ background-color: #f0f0f0;\r
+}\r
+\r
+#errorExplanation h2 {\r
+ text-align: left;\r
+ font-weight: bold;\r
+ padding: 5px 5px 5px 15px;\r
+ font-size: 12px;\r
+ margin: -7px;\r
+ background-color: #c00;\r
+ color: #fff;\r
+}\r
+\r
+#errorExplanation p {\r
+ color: #333;\r
+ margin-bottom: 0;\r
+ padding: 5px;\r
+}\r
+\r
+#errorExplanation ul li {\r
+ font-size: 12px;\r
+ list-style: square;\r
+}\r
+\r