Skip to content

Commit

Permalink
Update personal info before showControlCode #587
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Feb 3, 2025
1 parent a509e1c commit 4750c7a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 26 deletions.
59 changes: 34 additions & 25 deletions myconext-gui/src/routes/PersonalInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
deleteLinkedAccount,
iDINIssuers,
me,
preferLinkedAccount,
startLinkAccountFlow,
startVerifyAccountFlow,
Expand Down Expand Up @@ -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)}));
});
Expand Down Expand Up @@ -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)}));
});
}
Expand Down Expand Up @@ -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);
});
}
</script>

<style lang="scss">
Expand Down Expand Up @@ -556,7 +565,7 @@
<p class="banner-info">{I18n.t("ServiceDesk.ControlCode.Banner.COPY")}</p>
<Button label={I18n.t("ServiceDesk.ControlCode.ShowCode.COPY")}
className="ghost transparent"
onClick={() => showControlCode = true}/>
onClick={() => refreshControlCode()}/>
</div>
{/if}
<div class="inner-container second">
Expand Down Expand Up @@ -658,17 +667,17 @@

{#if showModal || showControlCode}
<Modal close={() => resetModalsAndQueryParams()}
title={showIdinOptions ? I18n.t("WelcomeToApp.VerifyYour.Highlight.COPY") : showControlCode ?
title={showIdinOptions ? I18n.t("WelcomeToApp.VerifyYour.Highlight.COPY") : showControlCode ?
I18n.t("ServiceDesk.ControlCode.ControlCode.COPY") : I18n.t("Profile.AddAnOrganisation.COPY")}
showOptions={false}>
<VerifyChoice addInstitution={addInstitution}
addBank={addBank}
addEuropean={addEuropean}
issuers={issuers}
showIdinOptions={showIdinOptions}
showServiceDesk={serviceDeskStart}
showControlCode={showControlCode}
cancel={() => resetModalsAndQueryParams()}/>
showOptions={false}>
<VerifyChoice addInstitution={addInstitution}
addBank={addBank}
addEuropean={addEuropean}
issuers={issuers}
showIdinOptions={showIdinOptions}
showServiceDesk={serviceDeskStart}
showControlCode={showControlCode}
cancel={() => resetModalsAndQueryParams()}/>
</Modal>
{/if}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ControlCode implements Serializable {
@Setter
@Indexed
private String code;

@Setter
private String documentId;
@Setter
private long createdAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class ExternalLinkedAccount implements Serializable, ProvisionedLinkedAcc
private boolean external = true;
@Setter
private boolean preferred;
@Setter
private String documentId;

public ExternalLinkedAccount(String subjectId, IdpScoping idpScoping, boolean external) {
this.subjectId = subjectId;
Expand Down Expand Up @@ -156,4 +158,5 @@ public String getFamilyName() {
}
return null;
}

}
6 changes: 6 additions & 0 deletions myconext-server/src/main/java/myconext/mongo/Migrations.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ public void deleteSessionAfterUserLastLoginDate(MongockTemplate mongoTemplate) {
mongoTemplate.remove(new Query(), "sessions");
}

@SuppressWarnings("unchecked")
@ChangeSet(order = "018", id = "deleteSessionAfterExternalLinkedAccountDocumentId", author = "[email protected]")
public void deleteSessionAfterExternalLinkedAccountDocumentId(MongockTemplate mongoTemplate) {
mongoTemplate.remove(new Query(), "sessions");
}

protected User mergeEduIDs(User user) {
List<EduID> eduIDS = user.getEduIDS();
//Make a copy to search in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public ExternalLinkedAccount createFromControlCode(ControlCode controlCode) {
//boolean external
true
);
externalLinkedAccount.setDocumentId(controlCode.getDocumentId());
externalLinkedAccount.setPreferred(true);
return externalLinkedAccount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void convertUserControlCode() {
.get("/myconext/api/servicedesk/user/{code}")
.as(ControlCode.class);
controlCode.setDayOfBirth("11 Mar 1987");
controlCode.setDocumentId("QWERTY");

given()
.when()
Expand All @@ -88,6 +89,8 @@ void convertUserControlCode() {
assertNull(user.getControlCode());

ExternalLinkedAccount externalLinkedAccount = user.getExternalLinkedAccounts().getFirst();
assertEquals(controlCode.getDocumentId(), externalLinkedAccount.getDocumentId());

DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder().appendPattern("dd-MM-yyyy").toFormatter();
ZonedDateTime dateOfBirth = externalLinkedAccount.getDateOfBirth().toInstant().atZone(ZoneId.systemDefault());
//See myconext-server/src/test/resources/users.json
Expand Down

0 comments on commit 4750c7a

Please sign in to comment.