Use new scim context functions
This commit is contained in:
parent
a5f6fddbdb
commit
04bd9dda9c
|
@ -214,6 +214,13 @@ export function doInEnvironmentContext(
|
|||
return newContext(updates, task)
|
||||
}
|
||||
|
||||
export function doInScimContext(task: any) {
|
||||
const updates: ContextMap = {
|
||||
scimCall: true,
|
||||
}
|
||||
return newContext(updates, task)
|
||||
}
|
||||
|
||||
export function getEnvironmentVariables() {
|
||||
const context = Context.get()
|
||||
if (!context.environmentVariables) {
|
||||
|
@ -270,3 +277,9 @@ export function getDevAppDB(opts?: any): Database {
|
|||
}
|
||||
return getDB(conversions.getDevelopmentAppID(appId), opts)
|
||||
}
|
||||
|
||||
export function isScimCall(): boolean {
|
||||
const context = Context.get()
|
||||
const scimCall = context?.scimCall
|
||||
return !!scimCall
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@ export type ContextMap = {
|
|||
appId?: string
|
||||
identity?: IdentityContext
|
||||
environmentVariables?: Record<string, string>
|
||||
scimCall?: boolean
|
||||
}
|
||||
|
|
|
@ -17,14 +17,12 @@ import {
|
|||
} from "@budibase/types"
|
||||
import { context } from "../.."
|
||||
|
||||
const isScim = () => (context.getIdentity() as any)?.isScimCall
|
||||
|
||||
async function created(user: User, timestamp?: number) {
|
||||
const properties: UserCreatedEvent = {
|
||||
userId: user._id as string,
|
||||
audited: {
|
||||
email: user.email,
|
||||
viaScim: isScim(),
|
||||
viaScim: context.isScimCall(),
|
||||
},
|
||||
}
|
||||
await publishEvent(Event.USER_CREATED, properties, timestamp)
|
||||
|
@ -35,7 +33,7 @@ async function updated(user: User) {
|
|||
userId: user._id as string,
|
||||
audited: {
|
||||
email: user.email,
|
||||
viaScim: isScim(),
|
||||
viaScim: context.isScimCall(),
|
||||
},
|
||||
}
|
||||
await publishEvent(Event.USER_UPDATED, properties)
|
||||
|
@ -46,7 +44,7 @@ async function deleted(user: User) {
|
|||
userId: user._id as string,
|
||||
audited: {
|
||||
email: user.email,
|
||||
viaScim: isScim(),
|
||||
viaScim: context.isScimCall(),
|
||||
},
|
||||
}
|
||||
await publishEvent(Event.USER_DELETED, properties)
|
||||
|
|
Loading…
Reference in New Issue