Skip to content
Snippets Groups Projects
Commit 385aab45 authored by Jonas Braathen's avatar Jonas Braathen
Browse files

Merge branch 'GREG-202-prevent-verify-fnr-flag' into 'master'

Add flag to prevent nin verification in frontend

See merge request !275
parents f9aca19d a6dd5745
No related branches found
No related tags found
1 merge request!275Add flag to prevent nin verification in frontend
Pipeline #115283 failed
...@@ -10,3 +10,5 @@ REACT_APP_SUPPORT_URL_EN=https://example.org/en ...@@ -10,3 +10,5 @@ REACT_APP_SUPPORT_URL_EN=https://example.org/en
REACT_APP_RESPONSIBLE_ORGANIZATION='Seksjon for integrasjon og elektroniske identiteter (INT)' REACT_APP_RESPONSIBLE_ORGANIZATION='Seksjon for integrasjon og elektroniske identiteter (INT)'
REACT_APP_RESPONSIBLE_ORGANIZATION_LINK='https://www.usit.uio.no/om/organisasjon/bnt/usitint/' REACT_APP_RESPONSIBLE_ORGANIZATION_LINK='https://www.usit.uio.no/om/organisasjon/bnt/usitint/'
REACT_APP_DISABLE_NIN_VERIFICATION='false'
...@@ -31,6 +31,10 @@ export const guestConsentStepEnabled: boolean = ...@@ -31,6 +31,10 @@ export const guestConsentStepEnabled: boolean =
export const availableInSearchEnabled: boolean = export const availableInSearchEnabled: boolean =
env.REACT_APP_AVAILABLE_IN_SEARCH_ENABLED === 'true' env.REACT_APP_AVAILABLE_IN_SEARCH_ENABLED === 'true'
/* Should nin verification be disabled for sponsors? */
export const disableNinVerification: boolean =
env.REACT_APP_DISABLE_NIN_VERIFICATION === 'true'
/* Footer content */ /* Footer content */
export const responsibleOrganization: string = export const responsibleOrganization: string =
env.REACT_APP_RESPONSIBLE_ORGANIZATION as string env.REACT_APP_RESPONSIBLE_ORGANIZATION as string
......
...@@ -6,7 +6,7 @@ import { submitJsonOpts } from 'utils' ...@@ -6,7 +6,7 @@ import { submitJsonOpts } from 'utils'
import CheckIcon from '@mui/icons-material/Check' import CheckIcon from '@mui/icons-material/Check'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { TableCell } from 'components/table' import { TableCell } from 'components/table'
import { appInst } from 'appConfig' import { appInst, disableNinVerification } from 'appConfig'
interface IdentityLineProps { interface IdentityLineProps {
text: string text: string
...@@ -53,7 +53,11 @@ const IdentityLine = ({ ...@@ -53,7 +53,11 @@ const IdentityLine = ({
<Button <Button
aria-label={t('button.verify')} aria-label={t('button.verify')}
onClick={() => setConfirmOpen(true)} onClick={() => setConfirmOpen(true)}
disabled={!identity} disabled={
!identity ||
(disableNinVerification &&
identity.type === 'norwegian_national_id_number')
}
> >
{t('button.verify')} {t('button.verify')}
</Button> </Button>
......
...@@ -334,3 +334,7 @@ NOTIFIER_SCHEDULE_TYPE = "W" ...@@ -334,3 +334,7 @@ NOTIFIER_SCHEDULE_TYPE = "W"
# Source used when creating identities that do not have a clear source like # Source used when creating identities that do not have a clear source like
# feide/id-porten # feide/id-porten
DEFAULT_IDENTITY_SOURCE = "greg" DEFAULT_IDENTITY_SOURCE = "greg"
# Toggle to prevent verification of NIN from the sponsor frontend.
# Introduced to prevent using greg for takeover of existing accounts in IGA.
DISABLE_NIN_VERIFY = False
from django.conf import settings
from django.utils import timezone from django.utils import timezone
from rest_framework import serializers from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from greg.models import Identity from greg.models import Identity
from gregui.models import GregUserProfile from gregui.models import GregUserProfile
...@@ -46,6 +48,15 @@ class IdentitySerializer(serializers.ModelSerializer): ...@@ -46,6 +48,15 @@ class IdentitySerializer(serializers.ModelSerializer):
Note: Get requests do not use this method, making it safe. Note: Get requests do not use this method, making it safe.
""" """
# Prevent nin verification. (This will only trigger if someone is posting the
# requests themselves. The frontend has its own setting disabling the button
# used against this endpoint.)
if settings.DISABLE_NIN_VERIFY and self.instance.type == str(
Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER
):
raise ValidationError(
detail="NIN verification currently disabled.",
)
attrs["verified"] = Identity.Verified.MANUAL attrs["verified"] = Identity.Verified.MANUAL
attrs["verified_by"] = self._get_sponsor() attrs["verified_by"] = self._get_sponsor()
attrs["verified_at"] = timezone.now() attrs["verified_at"] = timezone.now()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment