]> git.openstreetmap.org Git - rails.git/commitdiff
rest of password thing
authorSteve Coast <steve@asklater.com>
Fri, 17 Nov 2006 18:22:53 +0000 (18:22 +0000)
committerSteve Coast <steve@asklater.com>
Fri, 17 Nov 2006 18:22:53 +0000 (18:22 +0000)
app/controllers/user_controller.rb
app/models/notifier.rb
app/views/notifier/reset_password.rhtml [new file with mode: 0644]

index 659307460f57872cce1fabf267f0c1b14a11d39e..2b695ce7a83cc1c22d8950a16a1dd85cb8455fe9 100644 (file)
@@ -28,6 +28,22 @@ class UserController < ApplicationController
     end
   end
 
     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
 
   def new
   end
 
index fcc039b1f6dbc058ddcc0468eea04d040724e6db..4b80e1de8212dec993662130acf6501cf5e923aa 100644 (file)
@@ -10,8 +10,15 @@ class Notifier < ActionMailer::Base
   def lost_password( user )
     @recipients = user.email
     @from = 'abuse@openstreetmap.org'
   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
 
     @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
 end
diff --git a/app/views/notifier/reset_password.rhtml b/app/views/notifier/reset_password.rhtml
new file mode 100644 (file)
index 0000000..284e565
--- /dev/null
@@ -0,0 +1,3 @@
+Hi,
+
+Your password has been reset to <%= @pass %>