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