Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the provided user info sent to the audit endpoint to get which user is triggering an operation #4530

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions forge/routes/logging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ module.exports = async function (app) {
const auditEvent = request.body
const event = auditEvent.event
const error = auditEvent.error
const userId = auditEvent.user ? app.db.models.User.decodeHashid(auditEvent.user) : undefined
let user = request.session?.User || null
if (!user && auditEvent?.user && typeof auditEvent.user === 'string') {
user = await app.db.models.User.byId(auditEvent.user) || null
}
const userId = user?.id || null

// first check to see if the event is a known structured event
if (event === 'start-failed') {
Expand Down Expand Up @@ -114,7 +118,7 @@ module.exports = async function (app) {
setImmediate(async () => {
// when after the response is sent & IO is done, perform the snapshot
try {
const meta = { user: request.session.User }
const meta = { user }
const options = { clean: true, setAsTarget: false }
const snapshot = await snapshotController.doInstanceAutoSnapshot(request.project, auditEvent.type, options, meta)
if (!snapshot) {
Expand Down
Loading