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
43630ae3
Commit
43630ae3
authored
Jan 29, 2021
by
Serena Fang
Committed by
James Lopez
Jan 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log user approval/rejection in application logs
parent
13f7c2f3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
0 deletions
+32
-0
app/services/users/approve_service.rb
app/services/users/approve_service.rb
+5
-0
app/services/users/reject_service.rb
app/services/users/reject_service.rb
+6
-0
changelogs/unreleased/298783-log-user-instance-request-in-audit-events.yml
...ased/298783-log-user-instance-request-in-audit-events.yml
+5
-0
spec/services/users/approve_service_spec.rb
spec/services/users/approve_service_spec.rb
+8
-0
spec/services/users/reject_service_spec.rb
spec/services/users/reject_service_spec.rb
+8
-0
No files found.
app/services/users/approve_service.rb
View file @
43630ae3
...
...
@@ -17,6 +17,7 @@ module Users
user
.
accept_pending_invitations!
if
user
.
active_for_authentication?
DeviseMailer
.
user_admin_approval
(
user
).
deliver_later
log_event
(
user
)
after_approve_hook
(
user
)
success
(
message:
'Success'
,
http_status: :created
)
else
...
...
@@ -39,6 +40,10 @@ module Users
def
approval_required?
(
user
)
user
.
blocked_pending_approval?
end
def
log_event
(
user
)
Gitlab
::
AppLogger
.
info
(
message:
"User instance access request approved"
,
user:
"
#{
user
.
username
}
"
,
email:
"
#{
user
.
email
}
"
,
approved_by:
"
#{
current_user
.
username
}
"
,
ip_address:
"
#{
current_user
.
current_sign_in_ip
}
"
)
end
end
end
...
...
app/services/users/reject_service.rb
View file @
43630ae3
...
...
@@ -16,6 +16,8 @@ module Users
NotificationService
.
new
.
user_admin_rejection
(
user
.
name
,
user
.
email
)
log_event
(
user
)
success
end
...
...
@@ -30,6 +32,10 @@ module Users
def
after_reject_hook
(
user
)
# overridden by EE module
end
def
log_event
(
user
)
Gitlab
::
AppLogger
.
info
(
message:
"User instance access request rejected"
,
user:
"
#{
user
.
username
}
"
,
email:
"
#{
user
.
email
}
"
,
rejected_by:
"
#{
current_user
.
username
}
"
,
ip_address:
"
#{
current_user
.
current_sign_in_ip
}
"
)
end
end
end
...
...
changelogs/unreleased/298783-log-user-instance-request-in-audit-events.yml
0 → 100644
View file @
43630ae3
---
title
:
Log user approval/rejection in application logs
merge_request
:
51768
author
:
type
:
added
spec/services/users/approve_service_spec.rb
View file @
43630ae3
...
...
@@ -61,6 +61,14 @@ RSpec.describe Users::ApproveService do
expect
(
user
.
reload
).
to
be_active
end
it
'logs approval in application logs'
do
allow
(
Gitlab
::
AppLogger
).
to
receive
(
:info
)
subject
expect
(
Gitlab
::
AppLogger
).
to
have_received
(
:info
).
with
(
message:
"User instance access request approved"
,
user:
"
#{
user
.
username
}
"
,
email:
"
#{
user
.
email
}
"
,
approved_by:
"
#{
current_user
.
username
}
"
,
ip_address:
"
#{
current_user
.
current_sign_in_ip
}
"
)
end
it
'emails the user on approval'
do
expect
(
DeviseMailer
).
to
receive
(
:user_admin_approval
).
with
(
user
).
and_call_original
expect
{
subject
}.
to
have_enqueued_mail
(
DeviseMailer
,
:user_admin_approval
)
...
...
spec/services/users/reject_service_spec.rb
View file @
43630ae3
...
...
@@ -48,6 +48,14 @@ RSpec.describe Users::RejectService do
subject
end
it
'logs rejection in application logs'
do
allow
(
Gitlab
::
AppLogger
).
to
receive
(
:info
)
subject
expect
(
Gitlab
::
AppLogger
).
to
have_received
(
:info
).
with
(
message:
"User instance access request rejected"
,
user:
"
#{
user
.
username
}
"
,
email:
"
#{
user
.
email
}
"
,
rejected_by:
"
#{
current_user
.
username
}
"
,
ip_address:
"
#{
current_user
.
current_sign_in_ip
}
"
)
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