Skip to content

Commit

Permalink
delegation-to for access control
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnlaugurG committed Sep 26, 2024
1 parent 102d8db commit 18f03fc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
import { Features } from '@island.is/feature-flags'
import { FeatureFlagService } from '@island.is/nest/feature-flags'
import { LOGGER_PROVIDER } from '@island.is/logging'
import { DelegationDelegationType } from './models/delegation-delegation-type.model'
import { AuthDelegationType } from '@island.is/shared/types'

/**
* Service class for outgoing delegations.
Expand Down Expand Up @@ -103,7 +105,34 @@ export class DelegationsOutgoingService {
],
})

return delegations.map((d) => d.toDTO())
const delegationTypesDelegations = await this.delegationModel.findAll({
where: {
fromNationalId: user.nationalId,
},
include: [
{
model: DelegationDelegationType,
where: {
delegationTypeId: AuthDelegationType.GeneralMandate,
validTo: {
[Op.or]: {
[Op.gt]: new Date(),
[Op.is]: null,
},
},
},
required: true,
},
],
})

const delegationTypesDTO = delegationTypesDelegations.map((d) =>
d.toDTO(AuthDelegationType.GeneralMandate),
)

const delegationsDTO = delegations.map((d) => d.toDTO())

return [...delegationsDTO, ...delegationTypesDTO]
}

async findByOtherUser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import * as kennitala from 'kennitala'

import {
Box,
Text,
Stack,
Tag,
Inline,
Button,
Icon,
IconMapIcon as IconType,
Button,
Inline,
Stack,
Tag,
Text,
Tooltip,
} from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'
Expand Down Expand Up @@ -182,7 +182,9 @@ export const AccessCard = ({
<Box display="flex" justifyContent="spaceBetween" alignItems="flexStart">
<Stack space="smallGutter">
<Box display="flex" columnGap={2} alignItems="center">
{(isAdminView || !isOutgoing) && (
{(isAdminView ||
!isOutgoing ||
delegation.type === AuthDelegationType.GeneralMandate) && (
<>
{renderDelegationTypeLabel(delegation.type)}
{delegation.domain?.name && (
Expand Down

0 comments on commit 18f03fc

Please sign in to comment.