Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(delegation-api): Add GeneralMandate delegations to accessControl #16170

Merged
merged 6 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
GunnlaugurG marked this conversation as resolved.
Show resolved Hide resolved
[Op.is]: null,
},
},
},
required: true,
},
],
})

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

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

return [...delegationsDTO, ...delegationTypesDTO]
GunnlaugurG marked this conversation as resolved.
Show resolved Hide resolved
GunnlaugurG marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading