From 4750c7a066005ad86fd818acfc95354c1458dc9a Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Mon, 3 Feb 2025 13:32:39 +0100 Subject: [PATCH] Update personal info before showControlCode #587 --- myconext-gui/src/routes/PersonalInfo.svelte | 59 +++++++++++-------- .../main/java/myconext/model/ControlCode.java | 2 +- .../myconext/model/ExternalLinkedAccount.java | 3 + .../main/java/myconext/mongo/Migrations.java | 6 ++ .../java/myconext/verify/AttributeMapper.java | 1 + .../api/ServiceDeskControllerTest.java | 3 + 6 files changed, 48 insertions(+), 26 deletions(-) diff --git a/myconext-gui/src/routes/PersonalInfo.svelte b/myconext-gui/src/routes/PersonalInfo.svelte index 5408de17..e73ce632 100644 --- a/myconext-gui/src/routes/PersonalInfo.svelte +++ b/myconext-gui/src/routes/PersonalInfo.svelte @@ -9,6 +9,7 @@ import { deleteLinkedAccount, iDINIssuers, + me, preferLinkedAccount, startLinkAccountFlow, startVerifyAccountFlow, @@ -69,13 +70,8 @@ if (showConfirmation) { showPreferredInstitutionModal = true; } else { - preferLinkedAccount(preferredInstitution).then(json => { - for (let key in json) { - if (json.hasOwnProperty(key)) { - $user[key] = json[key]; - refresh(); - } - } + preferLinkedAccount(preferredInstitution).then(res => { + copyServerInformation(res); resetModalsAndQueryParams(); flash.setValue(I18n.t("profile.preferred", {name: institutionName(linkedAccount)})); }); @@ -108,14 +104,9 @@ if (showConfirmation) { showDeleteInstitutionModal = true; } else { - deleteLinkedAccount(linkedAccount).then(json => { + deleteLinkedAccount(linkedAccount).then(res => { showDeleteInstitutionModal = false; - for (let key in json) { - if (json.hasOwnProperty(key)) { - $user[key] = json[key]; - refresh(); - } - } + copyServerInformation(res); flash.setValue(I18n.t("Institution.Deleted.COPY", {name: institutionName(linkedAccount)})); }); } @@ -263,6 +254,24 @@ } }); + const copyServerInformation = res => { + for (let key in res) { + if (res.hasOwnProperty(key)) { + $user[key] = res[key]; + } + } + $user.controlCode = res.controlCode; + refresh(); + } + + const refreshControlCode = () => { + me().then(res => { + copyServerInformation(res); + showControlCode = !isEmpty(res.controlCode); + }); + + } +