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

fix(service-portal): Improve error handling when user tries to grant self access as actor #16408

Merged
merged 7 commits into from
Oct 16, 2024
4 changes: 4 additions & 0 deletions libs/portals/shared-modules/delegations/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export const m = defineMessages({
id: 'sp.access-control-delegations:grant-same-ssn',
defaultMessage: 'Ekki má veita sjálfum sér umboð',
},
grantActorSsn: {
id: 'sp.access-control-delegations:grant-actor-ssn',
defaultMessage: 'Sem umboðshafi má ekki veita sjálfum sér umboð',
},
grantCompanySsn: {
id: 'sp.access-control-delegations:grant-company-ssn',
defaultMessage: 'Ekki má veita fyrirtækjum umboð',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ const GrantAccess = () => {
value.length === 10 &&
kennitala.isValid(value) &&
!kennitala.isCompany(value) &&
value !== userInfo.profile.nationalId
value !== userInfo.profile.nationalId &&
value !== userInfo.profile.actor?.nationalId
) {
getIdentity({
variables: { input: { nationalId: value } },
Expand Down Expand Up @@ -207,6 +208,12 @@ const GrantAccess = () => {
return formatMessage(m.grantSameSsn)
}

if (
valueAsString === userInfo.profile.actor?.nationalId
) {
return formatMessage(m.grantActorSsn)
}

if (kennitala.isCompany(valueAsString)) {
return formatMessage(m.grantCompanySsn)
}
Expand Down