diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index d6e1da885..5070295d2 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -87,7 +87,7 @@ class AccountController < ApplicationController @user.must_change_passwd = false if @user.save @token.destroy - Mailer.password_updated(@user) + Mailer.password_updated(@user, { remote_ip: request.remote_ip }) flash[:notice] = l(:notice_account_password_updated) redirect_to signin_path return diff --git a/app/models/mailer.rb b/app/models/mailer.rb index fcaeee0a8..ba6a67757 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -311,7 +311,7 @@ class Mailer < ActionMailer::Base end # Notifies user that his password was updated - def self.password_updated(user) + def self.password_updated(user, options={}) # Don't send a notification to the dummy email address when changing the password # of the default admin account which is required after the first login # TODO: maybe not the best way to handle this @@ -320,6 +320,8 @@ class Mailer < ActionMailer::Base security_notification(user, message: :mail_body_password_updated, title: :button_change_password, + remote_ip: options[:remote_ip], + originator: user, url: {controller: 'my', action: 'password'} ).deliver end @@ -333,7 +335,6 @@ class Mailer < ActionMailer::Base end def security_notification(recipients, options={}) - redmine_headers 'Sender' => User.current.login @user = Array(recipients).detect{|r| r.is_a? User } set_language_if_valid(@user.try :language) @message = l(options[:message], @@ -341,7 +342,11 @@ class Mailer < ActionMailer::Base value: options[:value] ) @title = options[:title] && l(options[:title]) + @originator = options[:originator] || User.current + @remote_ip = options[:remote_ip] || @originator.remote_ip @url = options[:url] && (options[:url].is_a?(Hash) ? url_for(options[:url]) : options[:url]) + redmine_headers 'Sender' => @originator.login + redmine_headers 'Url' => @url mail :to => recipients, :subject => "[#{Setting.app_title}] #{l(:mail_subject_security_notification)}" end diff --git a/app/views/mailer/security_notification.html.erb b/app/views/mailer/security_notification.html.erb index 53bf0a0d5..309e9437f 100644 --- a/app/views/mailer/security_notification.html.erb +++ b/app/views/mailer/security_notification.html.erb @@ -7,7 +7,7 @@ <%= content_tag :h1, @title -%> <% end %>
-<%= l(:field_user) %>: <%= User.current.login %>
-<%= l(:field_remote_ip) %>: <%= User.current.remote_ip %>
+
<%= l(:field_user) %>: <%= @originator.login %>
+<%= l(:field_remote_ip) %>: <%= @remote_ip %>
<%= l(:label_date) %>: <%= format_time Time.now, true, @user %>