Skip to content

Commit

Permalink
log the response in resource and request in meta
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnlaugurG committed Oct 10, 2024
1 parent 6449052 commit 9e16ff4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,24 @@ export class DelegationAdminController {
async createByZendeskId(
@Body() { id }: ZendeskWebhookInputDto,
): Promise<void> {
await this.delegationAdminService.createDelegationByZendeskId(id)
await this.auditService.auditPromise(
{
system: true,
namespace,
action: 'createByZendeskId',
resources: (res) => {
return `id: ${res.id}, toNationalId: ${
res.toNationalId ?? 'Unknown'
}, fromNationalId: ${
res.fromNationalId ?? 'Unknown'
}, createdByNationalId: ${res.createdByNationalId ?? 'Unknown'}`
},
meta: {
id,
},
},
this.delegationAdminService.createDelegationByZendeskId(id),
)
}

@Delete(':delegationId')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class DelegationAdminCustomService {
}
}

async createDelegationByZendeskId(zendeskId: string): Promise<void> {
async createDelegationByZendeskId(zendeskId: string): Promise<DelegationDTO> {
const zendeskCase = await this.zendeskService.getTicket(zendeskId)

const {
Expand Down Expand Up @@ -181,13 +181,15 @@ export class DelegationAdminCustomService {

this.verifyTicketCompletion(zendeskCase)

await this.insertDelegation({
const resp = await this.insertDelegation({
fromNationalId,
toNationalId,
referenceId: zendeskId,
validTo: this.formatZendeskDate(validTo),
createdBy: createdByNationalId,
})

return resp.toDTO(AuthDelegationType.GeneralMandate)
}

async createDelegation(
Expand Down
4 changes: 4 additions & 0 deletions libs/auth-api-lib/src/lib/delegations/dto/delegation.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class DelegationDTO {
@ApiProperty()
toNationalId!: string

@IsString()
@ApiPropertyOptional()
createdByNationalId?: string

@IsString()
@ApiPropertyOptional({ nullable: true, type: String })
toName?: string | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export class Delegation extends Model<
fromNationalId: this.fromNationalId,
toNationalId: this.toNationalId,
toName: this.toName,
createdByNationalId: this.createdByNationalId,
validTo: this.validTo,
scopes: this.delegationScopes
? this.delegationScopes.map((scope) => scope.toDTO())
Expand Down

0 comments on commit 9e16ff4

Please sign in to comment.