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); + }); + + } +