Skip to content
Snippets Groups Projects
Commit e2c2faaf authored by Tore.Brede's avatar Tore.Brede
Browse files

Adding Feide ID to guest registation page if available

parent 630d1c54
No related branches found
No related tags found
1 merge request!121Adding Feide ID to guest registation page, adding success page in wizard
Pipeline #98020 failed
...@@ -97,5 +97,6 @@ ...@@ -97,5 +97,6 @@
"yourGuestPeriod": "Your guest period", "yourGuestPeriod": "Your guest period",
"guestPeriodDescription": "Period registered for your guest role." "guestPeriodDescription": "Period registered for your guest role."
}, },
"yourGuestAccount": "Your guest account" "yourGuestAccount": "Your guest account",
"feideId": "Feide ID"
} }
...@@ -96,5 +96,6 @@ ...@@ -96,5 +96,6 @@
"yourGuestPeriod": "Din gjesteperiode", "yourGuestPeriod": "Din gjesteperiode",
"guestPeriodDescription": "Registrert periode for din gjesterolle." "guestPeriodDescription": "Registrert periode for din gjesterolle."
}, },
"yourGuestAccount": "Din gjestekonto" "yourGuestAccount": "Din gjestekonto",
"feideId": "Feide ID"
} }
...@@ -97,5 +97,6 @@ ...@@ -97,5 +97,6 @@
"yourGuestPeriod": "Din gjesteperiode", "yourGuestPeriod": "Din gjesteperiode",
"guestPeriodDescription": "Registrert periode for di gjesterolle." "guestPeriodDescription": "Registrert periode for di gjesterolle."
}, },
"yourGuestAccount": "Din gjestekonto" "yourGuestAccount": "Din gjestekonto",
"feideId": "Feide ID"
} }
...@@ -16,6 +16,8 @@ export type GuestInviteInformation = { ...@@ -16,6 +16,8 @@ export type GuestInviteInformation = {
role_end: string role_end: string
comment?: string comment?: string
feide_id?: string
// These fields are in the form, but it is not expected that // These fields are in the form, but it is not expected that
// they are set, with the exception of e-mail, when the guest // they are set, with the exception of e-mail, when the guest
// first follows the invite link // first follows the invite link
......
...@@ -103,6 +103,7 @@ export default function GuestRegister() { ...@@ -103,6 +103,7 @@ export default function GuestRegister() {
comment: jsonResponse.role.comments, comment: jsonResponse.role.comments,
email: jsonResponse.person.email, email: jsonResponse.person.email,
feide_id: jsonResponse.person.feide_id,
mobile_phone_country_code: countryCode, mobile_phone_country_code: countryCode,
mobile_phone: nationalNumber, mobile_phone: nationalNumber,
fnr: jsonResponse.fnr, fnr: jsonResponse.fnr,
......
...@@ -158,6 +158,16 @@ const GuestRegisterStep = forwardRef( ...@@ -158,6 +158,16 @@ const GuestRegisterStep = forwardRef(
disabled disabled
/> />
{/* Only show the Feide ID field if the value is present */}
{guestData.feide_id && (
<TextField
id="feide_id"
label={t('feideId')}
value={guestData.feide_id}
disabled
/>
)}
<Box <Box
sx={{ sx={{
display: 'flex', display: 'flex',
......
from enum import Enum from enum import Enum
from typing import Optional
from django.core import exceptions from django.core import exceptions
from django.db import transaction from django.db import transaction
...@@ -12,7 +13,7 @@ from rest_framework.permissions import AllowAny ...@@ -12,7 +13,7 @@ from rest_framework.permissions import AllowAny
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView
from greg.models import Identity, InvitationLink from greg.models import Identity, InvitationLink, Person
from greg.permissions import IsSponsor from greg.permissions import IsSponsor
from gregui.api.serializers.guest import GuestRegisterSerializer from gregui.api.serializers.guest import GuestRegisterSerializer
from gregui.api.serializers.invitation import InviteGuestSerializer from gregui.api.serializers.invitation import InviteGuestSerializer
...@@ -141,19 +142,9 @@ class InvitedGuestView(GenericAPIView): ...@@ -141,19 +142,9 @@ class InvitedGuestView(GenericAPIView):
else SessionType.FEIDE.value else SessionType.FEIDE.value
) )
try: fnr = self._get_identity_or_none(person, Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER)
fnr = person.identities.get( passport = self._get_identity_or_none(person, Identity.IdentityType.PASSPORT_NUMBER)
type=Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER feide_id = self._get_identity_or_none(person, Identity.IdentityType.FEIDE_ID)
).value
except Identity.DoesNotExist:
fnr = None
try:
passport = person.identities.get(
type=Identity.IdentityType.PASSPORT_NUMBER
).value
except Identity.DoesNotExist:
passport = None
data = { data = {
"person": { "person": {
...@@ -163,6 +154,7 @@ class InvitedGuestView(GenericAPIView): ...@@ -163,6 +154,7 @@ class InvitedGuestView(GenericAPIView):
"mobile_phone": person.private_mobile and person.private_mobile.value, "mobile_phone": person.private_mobile and person.private_mobile.value,
"fnr": fnr, "fnr": fnr,
"passport": passport, "passport": passport,
"feide_id": feide_id
}, },
"sponsor": { "sponsor": {
"first_name": sponsor.first_name, "first_name": sponsor.first_name,
...@@ -247,3 +239,12 @@ class InvitedGuestView(GenericAPIView): ...@@ -247,3 +239,12 @@ class InvitedGuestView(GenericAPIView):
) )
# Check that there are no other fields filled in # Check that there are no other fields filled in
return number_of_fields_filled_in == len(person_data.keys()) return number_of_fields_filled_in == len(person_data.keys())
@staticmethod
def _get_identity_or_none(person: Person, identity_type: Identity.IdentityType) -> Optional[str]:
try:
return person.identities.get(
type=identity_type
).value
except Identity.DoesNotExist:
return None
...@@ -244,6 +244,7 @@ class GregOIDCBackend(ValidatingOIDCBackend): ...@@ -244,6 +244,7 @@ class GregOIDCBackend(ValidatingOIDCBackend):
person=person, person=person,
source=settings.FEIDE_SOURCE, source=settings.FEIDE_SOURCE,
verified=Identity.Verified.AUTOMATIC, verified=Identity.Verified.AUTOMATIC,
# TODO Should this be set at this stage or when the sponsor approves the identity?
verified_at=timezone.now(), verified_at=timezone.now(),
) )
identity.save() identity.save()
......
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