Skip to content

Commit

Permalink
fix: avoid crash when fields in subscriber are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciareinoso committed Jan 15, 2025
1 parent 5546543 commit 5af6a2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions components/SubscriberModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ const SubscriberModal = ({ toggleModal, subscriber, slices, deviceGroups, onSubm
const formik = useFormik<SubscriberValues>({
initialValues: {
imsi: rawIMSI || "",
opc: subscriber?.["AuthenticationSubscription"]["opc"]["opcValue"] || "",
key: subscriber?.["AuthenticationSubscription"]["permanentKey"]["permanentKeyValue"] || "",
sequenceNumber: subscriber?.["AuthenticationSubscription"]["sequenceNumber"] || "",
opc: subscriber?.["AuthenticationSubscription"]?.["opc"]?.["opcValue"] ?? "",
key: subscriber?.["AuthenticationSubscription"]?.["permanentKey"]?.["permanentKeyValue"] ?? "",
sequenceNumber: subscriber?.["AuthenticationSubscription"]?.["sequenceNumber"] ?? "",
selectedSlice: oldNetworkSliceName,
deviceGroup: oldDeviceGroupName,
},
Expand Down
6 changes: 5 additions & 1 deletion utils/editSubscriber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ const updateSubscriber = async (subscriberData: any, token: string) => {

// Workaround for https://github.com/omec-project/webconsole/issues/109
var existingSubscriberData = await getSubscriberResponse.json();
if (!getSubscriberResponse.ok || !existingSubscriberData["AuthenticationSubscription"]["authenticationMethod"]) {
if (!getSubscriberResponse.ok ||
(!existingSubscriberData["AuthenticationSubscription"]["authenticationMethod"] &&
!existingSubscriberData["AmPolicyData"]["subscCats"])) {
throw new Error("Subscriber does not exist.");
}

existingSubscriberData["AuthenticationSubscription"]["opc"] = existingSubscriberData["AuthenticationSubscription"]["opc"] ?? {};
existingSubscriberData["AuthenticationSubscription"]["opc"]["opcValue"] = subscriberData.opc;
existingSubscriberData["AuthenticationSubscription"]["permanentKey"] = existingSubscriberData["AuthenticationSubscription"]["permanentKey"] ?? {};
existingSubscriberData["AuthenticationSubscription"]["permanentKey"]["permanentKeyValue"] = subscriberData.key;
existingSubscriberData["AuthenticationSubscription"]["sequenceNumber"] = subscriberData.sequenceNumber;

Expand Down

0 comments on commit 5af6a2f

Please sign in to comment.