Further PR comments.

This commit is contained in:
mike12345567 2023-02-27 11:00:13 +00:00
parent 3e7c1d10cf
commit 65646ba01b
5 changed files with 8 additions and 17 deletions

View File

@ -225,12 +225,6 @@ export async function platformLogout(opts: PlatformLogoutOpts) {
const sessionIds = sessions.map(({ sessionId }) => sessionId) const sessionIds = sessions.map(({ sessionId }) => sessionId)
await invalidateSessions(userId, { sessionIds, reason: "logout" }) await invalidateSessions(userId, { sessionIds, reason: "logout" })
let user: User | undefined await events.auth.logout(ctx.user?.email)
try {
user = await userCache.getUser(userId)
} catch {
user = undefined
}
await events.auth.logout(user?.email)
await userCache.invalidateUser(userId) await userCache.invalidateUser(userId)
} }

View File

@ -3,10 +3,6 @@ import { processors } from "./processors"
import identification from "./identification" import identification from "./identification"
import * as backfill from "./backfill" import * as backfill from "./backfill"
export function isAudited(event: Event) {
return !!AuditedEventFriendlyName[event]
}
export const publishEvent = async ( export const publishEvent = async (
event: Event, event: Event,
properties: any, properties: any,

View File

@ -3,7 +3,6 @@ export * as processors from "./processors"
export * as analytics from "./analytics" export * as analytics from "./analytics"
export { default as identification } from "./identification" export { default as identification } from "./identification"
export * as backfillCache from "./backfill" export * as backfillCache from "./backfill"
export { isAudited } from "./events"
import { processors } from "./processors" import { processors } from "./processors"

View File

@ -4,11 +4,10 @@ import {
Group, Group,
IdentityType, IdentityType,
AuditLogQueueEvent, AuditLogQueueEvent,
AuditLogFn, AuditLogFn, AuditedEventFriendlyName,
} from "@budibase/types" } from "@budibase/types"
import { EventProcessor } from "./types" import { EventProcessor } from "./types"
import { getAppId } from "../../context" import { getAppId } from "../../context"
import { isAudited } from "../events"
import BullQueue from "bull" import BullQueue from "bull"
import { createQueue, JobQueue } from "../../queue" import { createQueue, JobQueue } from "../../queue"
@ -41,13 +40,17 @@ export default class AuditLogsProcessor implements EventProcessor {
}) })
} }
isAudited(event: Event) {
return !!AuditedEventFriendlyName[event]
}
async processEvent( async processEvent(
event: Event, event: Event,
identity: Identity, identity: Identity,
properties: any, properties: any,
timestamp?: string timestamp?: string
): Promise<void> { ): Promise<void> {
if (AuditLogsProcessor.auditLogsEnabled && isAudited(event)) { if (AuditLogsProcessor.auditLogsEnabled && this.isAudited(event)) {
// only audit log actual events, don't include backfills // only audit log actual events, don't include backfills
const userId = const userId =
identity.type === IdentityType.USER ? identity.id : undefined identity.type === IdentityType.USER ? identity.id : undefined

View File

@ -17,7 +17,6 @@ import * as pro from "@budibase/pro"
import * as api from "./api" import * as api from "./api"
import sdk from "./sdk" import sdk from "./sdk"
const pino = require("koa-pino-logger") const pino = require("koa-pino-logger")
import { sdk as proSdk } from "@budibase/pro"
let STARTUP_RAN = false let STARTUP_RAN = false
@ -127,7 +126,7 @@ export async function startup(app?: any, server?: any) {
let queuePromises = [] let queuePromises = []
// configure events to use the pro audit log write // configure events to use the pro audit log write
// can't integrate directly into backend-core due to cyclic issues // can't integrate directly into backend-core due to cyclic issues
queuePromises.push(events.processors.init(proSdk.auditLogs.write)) queuePromises.push(events.processors.init(pro.sdk.auditLogs.write))
queuePromises.push(automations.init()) queuePromises.push(automations.init())
queuePromises.push(initPro()) queuePromises.push(initPro())
if (app) { if (app) {