From: Steve Coast Date: Fri, 17 Nov 2006 18:22:53 +0000 (+0000) Subject: rest of password thing X-Git-Tag: live~8576 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/791814d74ed95e758f848c38b63d41d3f1b30553?hp=f864203056d2988b46b202f2cc00783378ee140a;ds=sidebyside rest of password thing --- diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 659307460..2b695ce7a 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -28,6 +28,22 @@ class UserController < ApplicationController end end + def reset_password + if params['token'] + user = User.find_by_token(params['token']) + if user + pass = User.make_token(8) + user.pass_crypt = pass + user.save + Notifier::deliver_reset_password(user, pass) + flash[:notice] = "You're password has been changed and is on the way to your mailbox :-)" + else + flash[:notice] = "Didn't find that token, check the URL maybe?" + end + end + redirect_to :action => 'login' + end + def new end diff --git a/app/models/notifier.rb b/app/models/notifier.rb index fcc039b1f..4b80e1de8 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -10,8 +10,15 @@ class Notifier < ActionMailer::Base def lost_password( user ) @recipients = user.email @from = 'abuse@openstreetmap.org' - @subject = '[OpenStreetMap] Passwors reset request' + @subject = '[OpenStreetMap] Password reset request' @body['url'] = "http://www.openstreetmap.org/user/reset_password?email=#{user.email}&token=#{user.token}" end + def reset_password(user, pass) + @recipients = user.email + @from = 'abuse@openstreetmap.org' + @subject = '[OpenStreetMap] Password reset' + @body['pass'] = pass + end + end diff --git a/app/views/notifier/reset_password.rhtml b/app/views/notifier/reset_password.rhtml new file mode 100644 index 000000000..284e565d0 --- /dev/null +++ b/app/views/notifier/reset_password.rhtml @@ -0,0 +1,3 @@ +Hi, + +Your password has been reset to <%= @pass %>