Add scim info in update/delete user events
This commit is contained in:
parent
6df08799bb
commit
648247b10e
|
@ -17,12 +17,14 @@ 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: !!(context.getIdentity() as any)?.isScimCall,
|
||||
viaScim: isScim(),
|
||||
},
|
||||
}
|
||||
await publishEvent(Event.USER_CREATED, properties, timestamp)
|
||||
|
@ -32,7 +34,8 @@ async function updated(user: User) {
|
|||
const properties: UserUpdatedEvent = {
|
||||
userId: user._id as string,
|
||||
audited: {
|
||||
email: user.email
|
||||
email: user.email,
|
||||
viaScim: isScim(),
|
||||
},
|
||||
}
|
||||
await publishEvent(Event.USER_UPDATED, properties)
|
||||
|
@ -43,6 +46,7 @@ async function deleted(user: User) {
|
|||
userId: user._id as string,
|
||||
audited: {
|
||||
email: user.email,
|
||||
viaScim: isScim(),
|
||||
},
|
||||
}
|
||||
await publishEvent(Event.USER_DELETED, properties)
|
||||
|
|
|
@ -199,8 +199,8 @@ export enum Event {
|
|||
export const AuditedEventFriendlyName: Record<Event, string | undefined> = {
|
||||
// USER
|
||||
[Event.USER_CREATED]: `User "{{ email }}" created{{#if viaScim}} via SCIM{{/if}}`,
|
||||
[Event.USER_UPDATED]: `User "{{ email }}" updated`,
|
||||
[Event.USER_DELETED]: `User "{{ email }}" deleted`,
|
||||
[Event.USER_UPDATED]: `User "{{ email }}" updated{{#if viaScim}} via SCIM{{/if}}`,
|
||||
[Event.USER_DELETED]: `User "{{ email }}" deleted{{#if viaScim}} via SCIM{{/if}}`,
|
||||
[Event.USER_PERMISSION_ADMIN_ASSIGNED]: `User "{{ email }}" admin role assigned`,
|
||||
[Event.USER_PERMISSION_ADMIN_REMOVED]: `User "{{ email }}" admin role removed`,
|
||||
[Event.USER_PERMISSION_BUILDER_ASSIGNED]: `User "{{ email }}" builder role assigned`,
|
||||
|
|
|
@ -4,21 +4,23 @@ export interface UserCreatedEvent extends BaseEvent {
|
|||
userId: string
|
||||
audited: {
|
||||
email: string
|
||||
viaScim: boolean
|
||||
viaScim?: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export interface UserUpdatedEvent extends BaseEvent {
|
||||
userId: string
|
||||
audited: {
|
||||
email: string
|
||||
email: string,
|
||||
viaScim?: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export interface UserDeletedEvent extends BaseEvent {
|
||||
userId: string
|
||||
audited: {
|
||||
email: string
|
||||
email: string,
|
||||
viaScim?: boolean
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue