Commit 3e267417 authored by James Lopez's avatar James Lopez

fix audit email when a confirmation is required

parent f2b624e5
class ConfirmationsController < Devise::ConfirmationsController class ConfirmationsController < Devise::ConfirmationsController
include EE::Audit::Changes
def almost_there def almost_there
flash[:notice] = nil flash[:notice] = nil
render layout: "devise_empty" render layout: "devise_empty"
...@@ -12,6 +14,8 @@ class ConfirmationsController < Devise::ConfirmationsController ...@@ -12,6 +14,8 @@ class ConfirmationsController < Devise::ConfirmationsController
def after_confirmation_path_for(resource_name, resource) def after_confirmation_path_for(resource_name, resource)
if signed_in?(resource_name) if signed_in?(resource_name)
audit_changes(:email, as: 'email address', model: resource)
after_sign_in_path_for(resource) after_sign_in_path_for(resource)
else else
flash[:notice] += " Please sign in." flash[:notice] += " Please sign in."
......
...@@ -3,6 +3,7 @@ module EE ...@@ -3,6 +3,7 @@ module EE
module Changes module Changes
def audit_changes(column, options = {}) def audit_changes(column, options = {})
column = options[:column] || column column = options[:column] || column
@model = options[:model]
return unless changed?(column) return unless changed?(column)
...@@ -12,7 +13,7 @@ module EE ...@@ -12,7 +13,7 @@ module EE
protected protected
def model def model
raise NotImplementedError, "#{self} does not implement #{__method__}" @model
end end
private private
...@@ -38,8 +39,8 @@ module EE ...@@ -38,8 +39,8 @@ module EE
end end
def audit_event(options) def audit_event(options)
::AuditEventService.new(@current_user, model, options). ::AuditEventService.new(@current_user, model, options)
for_changes.security_event .for_changes.security_event
end end
end end
end end
......
...@@ -15,7 +15,7 @@ describe EE::Audit::Changes do ...@@ -15,7 +15,7 @@ describe EE::Audit::Changes do
it 'does not call the audit event service' do it 'does not call the audit event service' do
user.update!(name: 'new name') user.update!(name: 'new name')
expect{ foo_instance.audit_changes(:email) }.not_to change { SecurityEvent.count } expect { foo_instance.audit_changes(:email) }.not_to change { SecurityEvent.count }
end end
end end
...@@ -23,7 +23,7 @@ describe EE::Audit::Changes do ...@@ -23,7 +23,7 @@ describe EE::Audit::Changes do
it 'calls the audit event service' do it 'calls the audit event service' do
user.update!(name: 'new name') user.update!(name: 'new name')
expect{ foo_instance.audit_changes(:name) }.to change { SecurityEvent.count }.by(1) expect { foo_instance.audit_changes(:name) }.to change { SecurityEvent.count }.by(1)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment