Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3e267417
Commit
3e267417
authored
Sep 15, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix audit email when a confirmation is required
parent
f2b624e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
app/controllers/confirmations_controller.rb
app/controllers/confirmations_controller.rb
+4
-0
lib/ee/audit/changes.rb
lib/ee/audit/changes.rb
+4
-3
spec/lib/ee/audit/changes_spec.rb
spec/lib/ee/audit/changes_spec.rb
+2
-2
No files found.
app/controllers/confirmations_controller.rb
View file @
3e267417
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."
...
...
lib/ee/audit/changes.rb
View file @
3e267417
...
@@ -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
...
...
spec/lib/ee/audit/changes_spec.rb
View file @
3e267417
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment