Skip to content

Commit

Permalink
Merge branch 'main' into fix/web-grant-sidemenu
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 21, 2024
2 parents ca3deb6 + 8d0e092 commit 41515a1
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,23 +431,26 @@ describe('MeClientsController with auth', () => {
slidingRefreshTokenLifetime:
typeSpecificDefaults.slidingRefreshTokenLifetime ??
clientBaseAttributes.slidingRefreshTokenLifetime,
accessTokenLifetime: clientBaseAttributes.accessTokenLifetime,
accessTokenLifetime:
typeSpecificDefaults.accessTokenLifetime ??
clientBaseAttributes.accessTokenLifetime,
allowOfflineAccess: clientBaseAttributes.allowOfflineAccess,
redirectUris: [],
postLogoutRedirectUris: [],
requireApiScopes: false,
requireConsent: false,
requirePkce: true,
supportTokenExchange: false,
requirePkce:
typeSpecificDefaults.requirePkce ?? clientBaseAttributes.requirePkce,
supportTokenExchange: typeSpecificDefaults.supportTokenExchange,
supportsCustomDelegation: false,
supportsLegalGuardians: false,
supportsPersonalRepresentatives: false,
supportsProcuringHolders: false,
promptDelegations: false,
customClaims: [],
customClaims: typeSpecificDefaults.customClaims ?? [],
singleSession: false,
supportedDelegationTypes: [],
allowedAcr: [defaultAcrValue],
allowedAcr: typeSpecificDefaults.allowedAcr ?? [defaultAcrValue],
})

// Assert - db record
Expand All @@ -468,9 +471,14 @@ describe('MeClientsController with auth', () => {
absoluteRefreshTokenLifetime:
typeSpecificDefaults.absoluteRefreshTokenLifetime ??
clientBaseAttributes.absoluteRefreshTokenLifetime,
accessTokenLifetime: clientBaseAttributes.accessTokenLifetime,
allowOfflineAccess: clientBaseAttributes.allowOfflineAccess,
requirePkce: clientBaseAttributes.requirePkce,
accessTokenLifetime:
typeSpecificDefaults.accessTokenLifetime ??
clientBaseAttributes.accessTokenLifetime,
allowOfflineAccess:
typeSpecificDefaults.allowOfflineAccess ??
clientBaseAttributes.allowOfflineAccess,
requirePkce:
typeSpecificDefaults.requirePkce ?? clientBaseAttributes.requirePkce,
refreshTokenExpiration: translateRefreshTokenExpiration(
typeSpecificDefaults.refreshTokenExpiration,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { SyslumennClientModule } from '@island.is/clients/syslumenn'

import { InheritanceReportService } from './inheritance-report.service'
import { NationalRegistryXRoadModule } from '@island.is/api/domains/national-registry-x-road'
import { AwsModule } from '@island.is/nest/aws'

@Module({
imports: [
SharedTemplateAPIModule,
SyslumennClientModule,
NationalRegistryXRoadModule,
AwsModule,
],
providers: [InheritanceReportService],
exports: [InheritanceReportService],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Inject, Injectable } from '@nestjs/common'
import {
Attachment,
DataUploadResponse,
Person,
PersonType,
Expand All @@ -18,6 +19,7 @@ import { inheritanceReportSchema } from '@island.is/application/templates/inheri
import type { Logger } from '@island.is/logging'
import { expandAnswers } from './utils/mappers'
import { NationalRegistryXRoadService } from '@island.is/api/domains/national-registry-x-road'
import { S3Service } from '@island.is/nest/aws'

type InheritanceSchema = zinfer<typeof inheritanceReportSchema>

Expand All @@ -27,6 +29,7 @@ export class InheritanceReportService extends BaseTemplateApiService {
@Inject(LOGGER_PROVIDER) private logger: Logger,
private readonly syslumennService: SyslumennService,
private readonly nationalRegistryService: NationalRegistryXRoadService,
private readonly s3Service: S3Service,
) {
super(ApplicationTypes.INHERITANCE_REPORT)
}
Expand Down Expand Up @@ -105,9 +108,44 @@ export class InheritanceReportService extends BaseTemplateApiService {

const uploadDataName = 'erfdafjarskysla1.0'
const uploadDataId = 'erfdafjarskysla1.0'
const attachments: Attachment[] = []

if (answers?.heirsAdditionalInfoPrivateTransferFiles) {
attachments.push(
...(await Promise.all(
answers.heirsAdditionalInfoPrivateTransferFiles.map(async (file) => {
const content = await this.getFileContentBase64(file.key)
return {
name: file.name,
content,
}
}),
)),
)
}

if (answers?.heirsAdditionalInfoFilesOtherDocuments) {
attachments.push(
...(await Promise.all(
answers.heirsAdditionalInfoFilesOtherDocuments.map(async (file) => {
const content = await this.getFileContentBase64(file.key)
return {
name: file.name,
content,
}
}),
)),
)
}

const result: DataUploadResponse = await this.syslumennService
.uploadData([person], undefined, uploadData, uploadDataName, uploadDataId)
.uploadData(
[person],
attachments,
uploadData,
uploadDataName,
uploadDataId,
)
.catch((e) => {
return {
success: false,
Expand All @@ -131,4 +169,17 @@ export class InheritanceReportService extends BaseTemplateApiService {
const spouse = await this.nationalRegistryService.getSpouse(auth.nationalId)
return { ...spouse, fullName: spouse?.name }
}

async getFileContentBase64(fileName: string): Promise<string> {
try {
const fileContent = await this.s3Service.getFileContent(
fileName,
'base64',
)
return fileContent || ''
} catch (e) {
this.logger.warn('[estate]: Failed to get file content - ', e)
return 'err'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export const NewMachineAnswersSchema = z.object({
streetRegistration: z
.object({
registerToTraffic: z.enum([YES, NO]),
size: z.enum(['1', '2', '3']),
size: z.enum(['1', '2', '3']).optional(),
})
.optional(),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,14 @@ export const inheritanceReportSchema = z.object({
}),

heirsAdditionalInfo: z.string().optional(),
heirsAdditionalInfoPrivateTransferFiles: z
.object({ key: z.string(), name: z.string() })
.array()
.optional(),
heirsAdditionalInfoFilesOtherDocuments: z
.object({ key: z.string(), name: z.string() })
.array()
.optional(),

spouse: z
.object({
Expand Down
17 changes: 1 addition & 16 deletions libs/auth-api-lib/src/lib/clients/admin/admin-clients.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,6 @@ export class AdminClientsService {
throw new BadRequestException('Invalid client id')
}

// If user is not super admin, we remove the super admin fields from the input to default to the client base attributes
if (!this.isSuperAdmin(user)) {
clientDto = {
clientId: clientDto.clientId,
clientType: clientDto.clientType,
clientName: clientDto.clientName,
// Remove defined super admin fields
...omit(clientDto, superUserFields),
// Remove personal representative from delegation types since it is not allowed for non-super admins
supportedDelegationTypes: delegationTypeSuperUserFilter(
clientDto.supportedDelegationTypes ?? [],
),
}
}

const {
customClaims,
displayName,
Expand Down Expand Up @@ -600,7 +585,7 @@ export class AdminClientsService {
client.supportedDelegationTypes?.map(
(clientDelegationType) => clientDelegationType.delegationType,
) ?? [],
allowedAcr: client.allowedAcr ?? [],
allowedAcr: client.allowedAcr.map((v) => v.toString()) ?? [],
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const OrganDonation = () => {
iAmOrganDonorWithExceptionsText: formatMessage(
m.iAmOrganDonorWithExceptionsText,
),
iAmNotOrganDonorText: formatMessage(m.iAmOrganDonorText),
iAmOrganDonorText: formatMessage(m.iAmNotOrganDonorText),
iAmNotOrganDonorText: formatMessage(m.iAmNotOrganDonorText),
iAmOrganDonorText: formatMessage(m.iAmOrganDonorText),
iAmOrganDonorWithExceptions: formatMessage(m.iAmOrganDonorWithExceptions),
iAmOrganDonor: formatMessage(m.iAmOrganDonor),
iAmNotOrganDonor: formatMessage(m.iAmNotOrganDonor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const OrganRegistrationForm = () => {
const formData = new FormData(e.currentTarget)
const data = Object.fromEntries(formData.entries())
const idKey = 'selected-limitations-'
const otherLimitations = data['otherLimitatons'].toString()
const otherLimitations = data['otherLimitatons']?.toString()
const limitations = Object.keys(data)
.filter((key) => key.includes(idKey))
.map((key) => key.replace(idKey, '').toLowerCase())
Expand Down

0 comments on commit 41515a1

Please sign in to comment.