diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index d61455bf1..659307460 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -1,11 +1,12 @@
class UserController < ApplicationController
-
+ layout 'site'
+
def save
@user = User.new(params[:user])
@user.set_defaults
if @user.save
- flash[:notice] = 'Users was successfully created.'
+ flash[:notice] = 'User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)'
Notifier::deliver_signup_confirm(@user)
redirect_to :action => 'login'
else
@@ -13,8 +14,21 @@ class UserController < ApplicationController
end
end
+ def lost_password
+ if params['user']['email']
+ user = User.find_by_email(params['user']['email'])
+ if user
+ user.token = User.make_token
+ user.save
+ Notifier::deliver_lost_password(user)
+ flash[:notice] = "Sorry you lost it :-( but an email is on it's way so you can reset it soon."
+ else
+ flash[:notice] = "Couldn't find that email address, sorry."
+ end
+ end
+ end
+
def new
- render :layout => 'site'
end
def login
@@ -29,10 +43,10 @@ class UserController < ApplicationController
session[:token] = u.token
redirect_to :controller => 'site', :action => 'index'
return
+ else
+ flash[:notice] = "Couldn't log in with those details"
end
end
-
- render :layout => 'site'
end
def logout
@@ -53,7 +67,7 @@ class UserController < ApplicationController
if @user && @user.active == 0
@user.active = true
@user.save
- flash[:notice] = 'Confirmed your account'
+ flash[:notice] = 'Confirmed your account, thanks for signing up!'
#FIXME: login the person magically
diff --git a/app/models/notifier.rb b/app/models/notifier.rb
index 484cb702f..fcc039b1f 100644
--- a/app/models/notifier.rb
+++ b/app/models/notifier.rb
@@ -1,12 +1,17 @@
class Notifier < ActionMailer::Base
def signup_confirm( user )
- # Email header info MUST be added here
@recipients = user.email
@from = 'abuse@openstreetmap.org'
@subject = '[OpenStreetMap] Confirm your email address'
-
@body['url'] = 'http://www.openstreetmap.org/user/confirm?confirm_string=' + user.token
end
-
+
+ def lost_password( user )
+ @recipients = user.email
+ @from = 'abuse@openstreetmap.org'
+ @subject = '[OpenStreetMap] Passwors reset request'
+ @body['url'] = "http://www.openstreetmap.org/user/reset_password?email=#{user.email}&token=#{user.token}"
+ end
+
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 350ea2c3a..c0468f8b0 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -32,11 +32,11 @@ class User < ActiveRecord::Base
find_first([ "token = ? ", token])
end
- def self.make_token
+ def self.make_token(length=30)
chars = 'abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
confirmstring = ''
- 30.times do
+ length.times do
confirmstring += chars[(rand * chars.length).to_i].chr
end
diff --git a/app/views/layouts/site.rhtml b/app/views/layouts/site.rhtml
index 5f0e848ac..70752f5e1 100644
--- a/app/views/layouts/site.rhtml
+++ b/app/views/layouts/site.rhtml
@@ -21,11 +21,11 @@
<% if @user %>
- Welcome, <%= @user.email %> |
- <%= link_to 'Logout', {:controller => 'user', :action => 'logout'}, {:id => 'loginanchor'}%>
+ Welcome, <%= @user.display_name %> |
+ <%= link_to 'logout', {:controller => 'user', :action => 'logout'}, {:id => 'loginanchor'}%>
<% else %>
- <%= link_to 'Login', {:controller => 'user', :action => 'login'}, {:id => 'loginanchor'}%> |
- <%= link_to 'Sign up', {:controller => 'user', :action => 'new'}, {:id => 'registeranchor'} %>
+ <%= link_to 'log in', {:controller => 'user', :action => 'login'}, {:id => 'loginanchor'}%> |
+ <%= link_to 'sign up', {:controller => 'user', :action => 'new'}, {:id => 'registeranchor'} %>
<% end %>
diff --git a/app/views/notifier/lost_password.rhtml b/app/views/notifier/lost_password.rhtml
new file mode 100644
index 000000000..78d3a51dd
--- /dev/null
+++ b/app/views/notifier/lost_password.rhtml
@@ -0,0 +1,8 @@
+Hi,
+
+Someone (possibly you) has asked for the password to be reset on this
+email addresses openstreetmap.org account.
+
+If this is you, please click the link below to reset your password.
+
+<%= @url %>
diff --git a/app/views/user/login.rhtml b/app/views/user/login.rhtml
index 88d207a14..31fe7e415 100644
--- a/app/views/user/login.rhtml
+++ b/app/views/user/login.rhtml
@@ -3,11 +3,11 @@ Please login or <%= link_to 'create an account', :controller => 'user', :action
<%= start_form_tag :action => 'login' %>
- Login name <%= text_field('user', 'email',{:size => 50, :maxlength => 255}) %>
+ email address: <%= text_field('user', 'email',{:size => 50, :maxlength => 255}) %>
password: <%= password_field('user', 'password',{:size => 50, :maxlength => 255}) %>
-<%= end_form_tag %> (<%= link_to 'Forgotten your password?', :controller => 'user', :action => 'lost_password' %>)
+<%= end_form_tag %> (<%= link_to 'Lost your password?', :controller => 'user', :action => 'lost_password' %>)
diff --git a/app/views/user/lost_password.rhtml b/app/views/user/lost_password.rhtml
new file mode 100644
index 000000000..ab60cd845
--- /dev/null
+++ b/app/views/user/lost_password.rhtml
@@ -0,0 +1,8 @@
+Forgotten Password?
+
+<%= start_form_tag :action => 'lost_password' %>
+
+ email address: <%= text_field('user', 'email', {:size => 50, :maxlength => 255} ) %>
+
+
+
diff --git a/app/views/user/new.rhtml b/app/views/user/new.rhtml
index bc237f0a9..681182321 100644
--- a/app/views/user/new.rhtml
+++ b/app/views/user/new.rhtml
@@ -1,14 +1,14 @@
Create a user account
Fill in the form and we'll send you a quick email to activate your account.
-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 this Creative Commons license.
+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 licensed under this this Creative Commons license (by-sa) .
<%= error_messages_for 'user' %>
<%= start_form_tag :action => 'save' %>
- email address: <%= text_field('user', 'email',{:size => 50, :maxlength => 255}) %>
- Login name <%= text_field('user', 'display_name',{:size => 50, :maxlength => 255}) %>
+ email: <%= text_field('user', 'email',{:size => 50, :maxlength => 255}) %>
+ login name <%= text_field('user', 'display_name',{:size => 50, :maxlength => 255}) %>
password: <%= password_field('user', 'pass_crypt',{:size => 50, :maxlength => 255}) %>
retype password: <%= password_field('user', 'pass_crypt_confirmation',{:size => 50, :maxlength => 255}) %>
diff --git a/config/routes.rb b/config/routes.rb
index 5c95e148d..4f898ea76 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -20,6 +20,7 @@ ActionController::Routing::Routes.draw do |map|
map.connect '/login.html', :controller => 'user', :action => 'login'
map.connect '/logout.html', :controller => 'user', :action => 'logout'
map.connect '/create-account.html', :controller => 'user', :action => 'new'
+ map.connect '/forgot-password.html', :controller => 'user', :action => 'lost_password'
map.connect ':controller/:action/:id'
end
diff --git a/public/stylesheets/site.css b/public/stylesheets/site.css
index 2a3896591..2c7e454db 100644
--- a/public/stylesheets/site.css
+++ b/public/stylesheets/site.css
@@ -1,4 +1,3 @@
-
a {
color: #0000ff;
text-decoration: none;
@@ -373,10 +372,8 @@ hides rule from IE5-Mac \*/
#notice {
width: 400px;
- border: 2px solid green;
+ border: 1px solid black;
padding: 7px;
- padding-bottom: 12px;
- margin-bottom: 20px;
background-color: #f0f0f0;
}
@@ -410,3 +407,6 @@ hides rule from IE5-Mac \*/
list-style: square;
}
+input {
+ border: 1px solid black;
+}