Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Injectable } from '@nestjs/common';
import { EventBus } from '@nestjs/cqrs';
import { type AuthenticatedContext } from '@amalia/kernel/auth/types';
import { RecordObject, RecordType } from '@amalia/tenants/monitoring/audit/types';
import { formatUserFullName } from '@amalia/tenants/users/types';
import { UserSignedOutEvent } from '../events/UserSignedOutEvent';
@Injectable()
export class LogoutUserUseCase {
public constructor(private readonly eventBus: EventBus) {}
public async execute({ authenticatedContext }: { authenticatedContext: AuthenticatedContext }) {
await this.eventBus.publish(
new UserSignedOutEvent({
authenticatedContext,
object: RecordObject.AUTHENTICATION,
type: RecordType.LOG,
values: {
target: {
id: authenticatedContext.user.id,
name: formatUserFullName(authenticatedContext.user),
},
newValues: {
action: 'Sign out',
},
},
}),
);
}
}
|