From d42e82eb2f48cc46dfb9260dce5c73c03b2039f5 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 18 Sep 2011 17:08:17 -0400 Subject: [PATCH] updated mailer urls --- app/models/user_password_reset_nonce.rb | 4 ++++ .../user/password_reset_mailer/confirmation.html.erb | 2 +- .../user/password_reset_mailer/reset_request.html.erb | 2 +- app/views/report_mailer/moderator_report.html.erb | 2 +- config/application.rb | 1 + config/schedule.rb | 4 ++++ 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/user_password_reset_nonce.rb b/app/models/user_password_reset_nonce.rb index 8dbd392e9..d54b9c52e 100644 --- a/app/models/user_password_reset_nonce.rb +++ b/app/models/user_password_reset_nonce.rb @@ -4,6 +4,10 @@ class UserPasswordResetNonce < ActiveRecord::Base before_validation :initialize_key, :on => :create after_create :deliver_notice + def self.prune! + destroy_all(["created_at < ?"], 1.week.ago) + end + def deliver_notice Maintenance::User::PasswordResetMailer.reset_request(user, self).deliver end diff --git a/app/views/maintenance/user/password_reset_mailer/confirmation.html.erb b/app/views/maintenance/user/password_reset_mailer/confirmation.html.erb index 9a7584d3f..21112a86a 100644 --- a/app/views/maintenance/user/password_reset_mailer/confirmation.html.erb +++ b/app/views/maintenance/user/password_reset_mailer/confirmation.html.erb @@ -2,4 +2,4 @@

The password for the user "<%= @user.name %>" for the website <%= Danbooru.config.app_name %> has been reset. It is now <%= @new_password %>.

-

Please log in to the website and <%= link_to "change your password", edit_user_path(@user, :host => Danbooru.config.hostname) %> as soon as possible.

+

Please log in to the website and <%= link_to "change your password", edit_user_path(@user) %> as soon as possible.

diff --git a/app/views/maintenance/user/password_reset_mailer/reset_request.html.erb b/app/views/maintenance/user/password_reset_mailer/reset_request.html.erb index 7bf58b0ca..ad4235d30 100644 --- a/app/views/maintenance/user/password_reset_mailer/reset_request.html.erb +++ b/app/views/maintenance/user/password_reset_mailer/reset_request.html.erb @@ -1,4 +1,4 @@

Password Reset Request

Someone has requested that the password for "<%= @user.name %>" for the website <%= Danbooru.config.app_name %> be reset. If you did not request this, then you can ignore this email.

-

To reset your password, please visit <%= link_to "this link", edit_maintenance_user_password_reset_path(:host => Danbooru.config.hostname, :key => @nonce.key, :email => @nonce.email) %>.

+

To reset your password, please visit <%= link_to "this link", edit_maintenance_user_password_reset_path(:key => @nonce.key, :email => @nonce.email) %>.

diff --git a/app/views/report_mailer/moderator_report.html.erb b/app/views/report_mailer/moderator_report.html.erb index 30799f158..ce5c38529 100644 --- a/app/views/report_mailer/moderator_report.html.erb +++ b/app/views/report_mailer/moderator_report.html.erb @@ -16,7 +16,7 @@ <% User.find(:all, :conditions => ["level >= ?", CONFIG["user_levels"]["Test Janitor"]], :order => "level, name").each do |user| %> - <%= link_to user.name, user_path(user, :host => Danbooru.config.hostname) %> + <%= link_to user.name, user_path(user) %> <%= user.pretty_level %> <%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 1.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 1.days.ago]) %> <%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 7.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 7.days.ago]) %> diff --git a/config/application.rb b/config/application.rb index 655d64665..5fb50c9f0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,5 +19,6 @@ module Danbooru config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = {:enable_starttls_auto => false} config.action_mailer.perform_deliveries = true + config.action_mailer.default_url_options = {:host => Danbooru.config.hostname, :only_path => false} end end diff --git a/config/schedule.rb b/config/schedule.rb index 6bf986368..24e977fe3 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -8,4 +8,8 @@ if environment == "production" every 1.hour do runner "AmazonBackup.execute" end + + every 1.week do + runner "UserPasswordResetNonce.prune!" + end end