From 0330eb7f39fa8b1fff4230c028b62c625b042acb Mon Sep 17 00:00:00 2001 From: irtiza-h30 Date: Mon, 23 Aug 2021 12:16:33 -0400 Subject: [PATCH] fixed OSU SSID edge case --- src/datasource.js | 52 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/datasource.js b/src/datasource.js index b0c6098..6d59844 100644 --- a/src/datasource.js +++ b/src/datasource.js @@ -267,6 +267,32 @@ export class API extends RESTDataSource { details: { passpointProfileId, passpointConfig }, } = profile; + const oldProfile = await this.get('portal/profile', { profileId: id }); + if (oldProfile.childProfileIds.length) { + const childProfiles = await this.get('portal/profile/inSet', { + profileIdSet: oldProfile.childProfileIds, + }); + const passpointProfile = childProfiles.find( + (profile) => profile.profileType === 'passpoint' + ); + if (passpointProfile) { + this.put('portal/profile', { + ...passpointProfile, + details: { + ...passpointProfile.details, + ...(passpointProfile.details.osuSsidProfileId === parseInt(id, 10) && { + osuSsidProfileId: null, + }), + ...(passpointProfile.details.associatedAccessSsidProfileIds && { + associatedAccessSsidProfileIds: passpointProfile.details.associatedAccessSsidProfileIds.filter( + (i) => i !== parseInt(id, 10) + ), + }), + }, + }); + } + } + if (passpointConfig === 'accessSSID') { this.get('portal/profile', { profileId: passpointProfileId.value, @@ -312,32 +338,6 @@ export class API extends RESTDataSource { }, }); }); - } else { - const oldProfile = await this.get('portal/profile', { profileId: id }); - if (oldProfile.childProfileIds.length) { - const childProfiles = await this.get('portal/profile/inSet', { - profileIdSet: oldProfile.childProfileIds, - }); - const passpointProfile = childProfiles.find( - (profile) => profile.profileType === 'passpoint' - ); - if (passpointProfile) { - this.put('portal/profile', { - ...passpointProfile, - details: { - ...passpointProfile.details, - ...(passpointProfile.details.osuSsidProfileId === parseInt(id, 10) && { - osuSsidProfileId: null, - }), - ...(passpointProfile.details.associatedAccessSsidProfileIds && { - associatedAccessSsidProfileIds: passpointProfile.details.associatedAccessSsidProfileIds.filter( - (i) => i !== parseInt(id, 10) - ), - }), - }, - }); - } - } } }