From b44675819cd372b4e41ec221877d0c9444b0b91a Mon Sep 17 00:00:00 2001 From: Tore Brede <Tore.Brede@uib.no> Date: Tue, 19 Oct 2021 15:23:31 +0200 Subject: [PATCH] GREG-85: Fixing problem with wrong data inserted into response --- frontend/src/routes/guest/register/index.tsx | 2 ++ gregui/api/views/invitation.py | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/routes/guest/register/index.tsx b/frontend/src/routes/guest/register/index.tsx index b50611a6..8dc410be 100644 --- a/frontend/src/routes/guest/register/index.tsx +++ b/frontend/src/routes/guest/register/index.tsx @@ -61,6 +61,8 @@ export default function GuestRegister() { if (response.ok) { response.json().then((jsonResponse) => { + console.log(`Guest data from server: ${JSON.stringify(jsonResponse)}`) + const authenticationMethod = jsonResponse.meta.form_type === 'manual' ? AuthenticationMethod.NationalIdNumberOrPassport diff --git a/gregui/api/views/invitation.py b/gregui/api/views/invitation.py index f356a035..c1d91fef 100644 --- a/gregui/api/views/invitation.py +++ b/gregui/api/views/invitation.py @@ -1,6 +1,8 @@ import json import datetime from uuid import uuid4 + +from django.contrib.auth.models import AnonymousUser from django.core import exceptions from django.db import transaction from django.http.response import JsonResponse @@ -133,11 +135,12 @@ class InvitedGuestView(GenericAPIView): sponsor = role.sponsor_id # If the user is not logged in then tell the client to take him through the manual registration process - is_not_logged_in = request.user + is_not_logged_in = request.user.is_anonymous fnr_verified = False try: - fnr = person.identities.get(type=Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER) + fnr_identity = person.identities.get(type=Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER) + fnr = fnr_identity.value # TODO Maybe other criteria should be specified here if fnr.verified == Identity.Verified.AUTOMATIC: fnr_verified = True @@ -155,7 +158,7 @@ class InvitedGuestView(GenericAPIView): "last_name": person.last_name, "email": person.private_email and person.private_email.value, "mobile_phone": person.private_mobile and person.private_mobile.value, - "fnr": fnr and fnr.value, + "fnr": fnr, "passport": passport, }, "sponsor": { @@ -172,7 +175,7 @@ class InvitedGuestView(GenericAPIView): "comments": role.comments, }, "meta": { - "form_type": is_not_logged_in, + "form_type": "manual" if is_not_logged_in else "feide", "fnr_verified": fnr_verified, } } -- GitLab