Skip to content

Commit

Permalink
Use post.
Browse files Browse the repository at this point in the history
  • Loading branch information
valurefugl committed Sep 19, 2024
1 parent 562f5c2 commit 5c330b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiProperty } from '@nestjs/swagger'
import { Type } from 'class-transformer'
import { IsArray, IsString } from 'class-validator'

export class DelegationVerification {
@IsString()
@ApiProperty()
fromNationalId!: string

@IsArray()
@Type(() => String)
@ApiProperty({ type: [String] })
delegationTypes!: string[]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {
Body,
Controller,
Get,
Headers,
Inject,
ParseArrayPipe,
Post,
Query,
UseGuards,
Version,
Expand All @@ -29,6 +30,7 @@ import { LOGGER_PROVIDER } from '@island.is/logging'
import { AuthDelegationType } from '@island.is/shared/types'

import { DelegationVerificationResult } from './delegation-verification-result.dto'
import { DelegationVerification } from './delegation-verification.dto'

import type { Logger } from '@island.is/logging'
import type { User } from '@island.is/auth-nest-tools'
Expand Down Expand Up @@ -115,22 +117,18 @@ export class DelegationsController {
}

@Scopes('@identityserver.api/authentication')
@Get('verify')
@Post('verify')
@ApiOkResponse({ type: DelegationVerificationResult })
async verify(
@CurrentUser() user: User,
@Headers('X-Query-From-National-Id')
fromNationalId: string,
@Query('delegationType')
delegationType: AuthDelegationType[],
@Body()
request: DelegationVerification,
): Promise<DelegationVerificationResult> {
if (!Array.isArray(delegationType)) delegationType = [delegationType]

const verified =
await this.delegationsIncomingService.verifyDelegationAtProvider(
user,
fromNationalId,
delegationType,
request.fromNationalId,
request.delegationTypes as AuthDelegationType[],
)

return { verified }
Expand Down

0 comments on commit 5c330b7

Please sign in to comment.