From 7448339ab0e3954be1471d247b451200e06a8ba7 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Mon, 8 Oct 2007 20:27:01 +0000 Subject: [PATCH] ActionItem78: checkpoint --- app/models/change_password.rb | 23 +++++++++++++++++++++++ app/models/task_mailer.rb | 10 +++++++++- config/routes.rb | 3 +++ db/migrate/017_create_tasks.rb | 2 ++ test/unit/task_test.rb | 4 ++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/models/change_password.rb b/app/models/change_password.rb index ab57786..4860b6c 100644 --- a/app/models/change_password.rb +++ b/app/models/change_password.rb @@ -49,4 +49,27 @@ class ChangePassword < Task user.force_change_password!(self.password, self.password_confirmation) end + # overriding messages + + def cancel_message + _('Your password change request was cancelled at %s.') % Time.now.to_s + end + + def finish_message + _('Your password was changed successfully.') + end + + def create_message + hostname = self.requestor.environment.default_hostname + hash = self.id + + lambda do + _("In order to change your password, please visit the following address:\n\n%s") % url_for(:host => hostname, :controller => 'account', :action => 'change_password', :hash => hash) + end + end + + def description + _('Password change request') + end + end diff --git a/app/models/task_mailer.rb b/app/models/task_mailer.rb index de98a09..18b5782 100644 --- a/app/models/task_mailer.rb +++ b/app/models/task_mailer.rb @@ -15,11 +15,19 @@ class TaskMailer < ActionMailer::Base protected def send_message(task, message) + + text = + if message.kind_of?(Proc) + self.instance_eval(&message) + else + message + end + recipients task.requestor.email from task.requestor.environment.contact_email subject task.description body :requestor => task.requestor.name, - :message => message, + :message => text, :environment => task.requestor.environment.name, :url => url_for(:host => task.requestor.environment.default_hostname, :controller => 'home') end diff --git a/config/routes.rb b/config/routes.rb index 6455588..2c598c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,7 +19,10 @@ ActionController::Routing::Routes.draw do |map| map.connect 'doc', :controller => 'doc' # user account controller + map.connect 'account/change_password/:hash', :controller => 'account', :action => 'change_password' + map.connect 'account/:action', :controller => 'account' + ###################################################### ## Controllers that are profile-specific (for profile admins ) diff --git a/db/migrate/017_create_tasks.rb b/db/migrate/017_create_tasks.rb index 6e5778e..26ccdec 100644 --- a/db/migrate/017_create_tasks.rb +++ b/db/migrate/017_create_tasks.rb @@ -7,6 +7,8 @@ class CreateTasks < ActiveRecord::Migration t.column :requestor_id, :integer t.column :target_id, :integer + + t.column :hash, :string end end diff --git a/test/unit/task_test.rb b/test/unit/task_test.rb index d2045c3..89a7e46 100644 --- a/test/unit/task_test.rb +++ b/test/unit/task_test.rb @@ -88,5 +88,9 @@ class TaskTest < Test::Unit::TestCase task.save! end + should 'generate a random hash when creating' do + flunk 'not implemented yet' + end + end -- libgit2 0.21.2