First half of a password reset function

This commit is contained in:
Steve Coast 2006-11-17 13:31:15 +00:00
parent e62fe92282
commit f864203056
10 changed files with 60 additions and 24 deletions

View file

@ -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

View file

@ -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