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

fix audit email when a confirmation is required

parent f2b624e5
class ConfirmationsController < Devise::ConfirmationsController
include EE::Audit::Changes
def almost_there
flash[:notice] = nil
render layout: "devise_empty"
......@@ -12,6 +14,8 @@ class ConfirmationsController < Devise::ConfirmationsController
def after_confirmation_path_for(resource_name, resource)
if signed_in?(resource_name)
audit_changes(:email, as: 'email address', model: resource)
after_sign_in_path_for(resource)
else
flash[:notice] += " Please sign in."
......
......@@ -3,6 +3,7 @@ module EE
module Changes
def audit_changes(column, options = {})
column = options[:column] || column
@model = options[:model]
return unless changed?(column)
......@@ -12,7 +13,7 @@ module EE
protected
def model
raise NotImplementedError, "#{self} does not implement #{__method__}"
@model
end
private
......@@ -38,8 +39,8 @@ module EE
end
def audit_event(options)
::AuditEventService.new(@current_user, model, options).
for_changes.security_event
::AuditEventService.new(@current_user, model, options)
.for_changes.security_event
end
end
end
......
......@@ -15,7 +15,7 @@ describe EE::Audit::Changes do
it 'does not call the audit event service' do
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
......@@ -23,7 +23,7 @@ describe EE::Audit::Changes do
it 'calls the audit event service' do
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
......
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