Skip to content

Commit

Permalink
fix(service-portal): Improve error handling when user tries to grant …
Browse files Browse the repository at this point in the history
…self access as actor (#16408)

* Improve error handling when user tries to grant self access as actor

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 16, 2024
1 parent be38ab0 commit f7773d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit f7773d8

Please sign in to comment.