diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index dc3326b..b190936 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -479,6 +479,13 @@ func (h *MenuHandlers) ConfirmPinChange(ctx context.Context, sym string, input [ return res, err } + // clear the temporary value as it has been used + err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } + return res, nil } @@ -515,6 +522,13 @@ func (h *MenuHandlers) ResetOthersPin(ctx context.Context, sym string, input []b return res, err } + // clear the temporary value as it has been used + err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } + return res, nil } @@ -681,6 +695,12 @@ func (h *MenuHandlers) SaveFirstname(ctx context.Context, sym string, input []by if err != nil { return res, err } + // clear the temporary value as it has been used + err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } res.FlagSet = append(res.FlagSet, flag_firstname_set) } else { if firstNameSet { @@ -721,6 +741,12 @@ func (h *MenuHandlers) SaveFamilyname(ctx context.Context, sym string, input []b logg.ErrorCtxf(ctx, "failed to write familyName entry with", "key", storedb.DATA_FAMILY_NAME, "value", temporaryFamilyName, "error", err) return res, err } + // clear the temporary value as it has been used + err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } res.FlagSet = append(res.FlagSet, flag_familyname_set) } else { if familyNameSet { @@ -791,6 +817,12 @@ func (h *MenuHandlers) SaveYob(ctx context.Context, sym string, input []byte) (r logg.ErrorCtxf(ctx, "failed to write yob entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", temporaryYob, "error", err) return res, err } + // clear the temporary value as it has been used + err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } res.FlagSet = append(res.FlagSet, flag_yob_set) } else { if yobSet { @@ -830,6 +862,12 @@ func (h *MenuHandlers) SaveLocation(ctx context.Context, sym string, input []byt logg.ErrorCtxf(ctx, "failed to write location entry with", "key", storedb.DATA_LOCATION, "value", temporaryLocation, "error", err) return res, err } + // clear the temporary value as it has been used + err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } res.FlagSet = append(res.FlagSet, flag_location_set) } else { if locationSet { @@ -871,6 +909,12 @@ func (h *MenuHandlers) SaveGender(ctx context.Context, sym string, input []byte) logg.ErrorCtxf(ctx, "failed to write gender entry with", "key", storedb.DATA_GENDER, "value", gender, "error", err) return res, err } + // clear the temporary value as it has been used + err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } res.FlagSet = append(res.FlagSet, flag_gender_set) } else { if genderSet { @@ -912,6 +956,12 @@ func (h *MenuHandlers) SaveOfferings(ctx context.Context, sym string, input []by logg.ErrorCtxf(ctx, "failed to write offerings entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", offerings, "error", err) return res, err } + // clear the temporary value as it has been used + err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } res.FlagSet = append(res.FlagSet, flag_offerings_set) } else { if offeringsSet { @@ -1584,6 +1634,12 @@ func (h *MenuHandlers) InviteValidRecipient(ctx context.Context, sym string, inp // res.Content = l.Get("Your invitation to %s to join Sarafu Network has been sent.", string(recipient)) res.Content = l.Get("Your invite request for %s to Sarafu Network failed. Please try again later.", string(recipient)) + // clear the temporary value as it has been used + err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("")) + if err != nil { + logg.ErrorCtxf(ctx, "failed to clear DATA_TEMPORARY_VALUE entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", "empty", "error", err) + return res, err + } return res, nil }