diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index e998bd5..0e40cb5 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -241,21 +241,24 @@ func (h *Handlers) SaveTemporaryPin(ctx context.Context, sym string, input []byt accountPIN := string(input) - // Validate that the PIN is a 4-digit number - if !isValidPIN(accountPIN) { - res.FlagSet = append(res.FlagSet, flag_incorrect_pin) + if accountPIN != "0" { // for the 0:Back case + // Validate that the PIN is a 4-digit number + if !isValidPIN(accountPIN) { + res.FlagSet = append(res.FlagSet, flag_incorrect_pin) + return res, nil + } + store := h.userdataStore + err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_PIN, []byte(accountPIN)) + if err != nil { + return res, err + } return res, nil } - store := h.userdataStore - err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_PIN, []byte(accountPIN)) - if err != nil { - return res, err - } + return res, nil } - -func (h *Handlers) GetVoucherList(ctx context.Context,sym string,input []byte) (resource.Result,error){ +func (h *Handlers) GetVoucherList(ctx context.Context, sym string, input []byte) (resource.Result, error) { var res resource.Result vouchers := []string{ "SRF", @@ -286,9 +289,9 @@ func (h *Handlers) GetVoucherList(ctx context.Context,sym string,input []byte) ( for i, voucher := range vouchers { numberedVouchers = append(numberedVouchers, fmt.Sprintf("%d:%s", i+1, voucher)) } - res.Content = strings.Join(numberedVouchers,"\n") + res.Content = strings.Join(numberedVouchers, "\n") - return res,nil + return res, nil } func (h *Handlers) ConfirmPinChange(ctx context.Context, sym string, input []byte) (resource.Result, error) { @@ -577,7 +580,7 @@ func (h *Handlers) Authorize(ctx context.Context, sym string, input []byte) (res if err != nil { return res, err } - if len(input) == 4 { + if len(input) > 1 { if bytes.Equal(input, AccountPin) { if h.st.MatchFlag(flag_account_authorized, false) { res.FlagReset = append(res.FlagReset, flag_incorrect_pin) diff --git a/services/registration/confirm_pin_change b/services/registration/confirm_pin_change index 398a827..2e1b83e 100644 --- a/services/registration/confirm_pin_change +++ b/services/registration/confirm_pin_change @@ -1 +1 @@ -Confirm your new PIN: +Confirm your new PIN: \ No newline at end of file diff --git a/services/registration/confirm_pin_change.vis b/services/registration/confirm_pin_change.vis index 7691e01..269e83c 100644 --- a/services/registration/confirm_pin_change.vis +++ b/services/registration/confirm_pin_change.vis @@ -2,6 +2,4 @@ CATCH invalid_pin flag_valid_pin 0 MOUT back 0 HALT INCMP _ 0 -INCMP * pin_reset_success - - +INCMP pin_reset_success * diff --git a/services/registration/confirm_pin_change_swa b/services/registration/confirm_pin_change_swa index c7af4ea..e407fec 100644 --- a/services/registration/confirm_pin_change_swa +++ b/services/registration/confirm_pin_change_swa @@ -1 +1 @@ -Thibitisha PIN yako mpya: +Thibitisha PIN yako mpya: \ No newline at end of file diff --git a/services/registration/enter_familyname_swa b/services/registration/enter_familyname_swa index 82f64cd..48a38b2 100644 --- a/services/registration/enter_familyname_swa +++ b/services/registration/enter_familyname_swa @@ -1 +1 @@ -Weka jina la familia +Weka jina la familia \ No newline at end of file diff --git a/services/registration/enter_name.vis b/services/registration/enter_name.vis index 563577e..2703068 100644 --- a/services/registration/enter_name.vis +++ b/services/registration/enter_name.vis @@ -7,6 +7,3 @@ HALT RELOAD save_firstname INCMP _ 0 INCMP pin_entry * - - - diff --git a/services/registration/invalid_pin_swa b/services/registration/invalid_pin_swa index 1817570..fd2509f 100644 --- a/services/registration/invalid_pin_swa +++ b/services/registration/invalid_pin_swa @@ -1 +1,2 @@ -PIN mpya na udhibitisho wa pin mpya hazilingani.Tafadhali jaribu tena.Kwa usaidizi piga simu +254757628885. +PIN mpya na udhibitisho wa PIN mpya hazilingani. Tafadhali jaribu tena. +Kwa usaidizi piga simu +254757628885. \ No newline at end of file diff --git a/services/registration/my_vouchers.vis b/services/registration/my_vouchers.vis index b70dbfa..9702573 100644 --- a/services/registration/my_vouchers.vis +++ b/services/registration/my_vouchers.vis @@ -4,6 +4,3 @@ MOUT back 0 HALT INCMP _ 0 INCMP select_voucher 1 - - - diff --git a/services/registration/new_pin b/services/registration/new_pin index bae2814..c2d654e 100644 --- a/services/registration/new_pin +++ b/services/registration/new_pin @@ -1 +1 @@ -Enter a new four number pin +Enter a new four number PIN \ No newline at end of file diff --git a/services/registration/new_pin.vis b/services/registration/new_pin.vis index 29013a9..ddcb7cc 100644 --- a/services/registration/new_pin.vis +++ b/services/registration/new_pin.vis @@ -1,13 +1,10 @@ -LOAD authorize_account 12 -RELOAD authorize_account -CATCH incorrect_pin flag_incorrect_pin 1 -CATCH old_pin flag_allow_update 0 +CATCH _ flag_allow_update 0 MOUT back 0 HALT INCMP _ 0 LOAD save_temporary_pin 6 -LOAD verify_new_pin 0 RELOAD save_temporary_pin +LOAD verify_new_pin 8 RELOAD verify_new_pin -INCMP * confirm_pin_change - +CATCH incorrect_pin flag_incorrect_pin 1 +INCMP confirm_pin_change * diff --git a/services/registration/new_pin_swa b/services/registration/new_pin_swa index 1ec32d9..a2dc212 100644 --- a/services/registration/new_pin_swa +++ b/services/registration/new_pin_swa @@ -1,2 +1 @@ -Weka PIN mpya ya nne nambari: - +Weka PIN mpya ya nne nambari: \ No newline at end of file diff --git a/services/registration/old_pin b/services/registration/old_pin index 2c64d42..798d1ce 100644 --- a/services/registration/old_pin +++ b/services/registration/old_pin @@ -1 +1 @@ -Enter your old PIN +Enter your old PIN \ No newline at end of file diff --git a/services/registration/old_pin.vis b/services/registration/old_pin.vis index 1e99f4f..52379eb 100644 --- a/services/registration/old_pin.vis +++ b/services/registration/old_pin.vis @@ -1,7 +1,9 @@ LOAD reset_allow_update 0 +RELOAD reset_allow_update MOUT back 0 HALT -RELOAD reset_allow_update +LOAD authorize_account 12 +RELOAD authorize_account +CATCH incorrect_pin flag_incorrect_pin 1 INCMP _ 0 INCMP new_pin * - diff --git a/services/registration/old_pin_swa b/services/registration/old_pin_swa index 312b597..e082773 100644 --- a/services/registration/old_pin_swa +++ b/services/registration/old_pin_swa @@ -1 +1 @@ -Weka PIN yako ya zamani: +Weka PIN yako ya zamani: \ No newline at end of file diff --git a/services/registration/pin_management.vis b/services/registration/pin_management.vis index 3b33dad..86b5bb3 100644 --- a/services/registration/pin_management.vis +++ b/services/registration/pin_management.vis @@ -4,5 +4,4 @@ MOUT guard_pin 3 MOUT back 0 HALT INCMP _ 0 -INCMP old_pin 1 - +INCMP old_pin 1 diff --git a/services/registration/pin_reset_mismatch b/services/registration/pin_reset_mismatch index dc0236b..e75068c 100644 --- a/services/registration/pin_reset_mismatch +++ b/services/registration/pin_reset_mismatch @@ -1 +1 @@ -The PIN is not a match. Try again +The PIN is not a match. Try again \ No newline at end of file diff --git a/services/registration/pin_reset_mismatch.vis b/services/registration/pin_reset_mismatch.vis index 5dc7e7c..b0d4a44 100644 --- a/services/registration/pin_reset_mismatch.vis +++ b/services/registration/pin_reset_mismatch.vis @@ -3,4 +3,3 @@ MOUT quit 9 HALT INCMP confirm_pin_change 1 INCMP quit 9 - diff --git a/services/registration/pin_reset_success b/services/registration/pin_reset_success index e9326ec..47a0fcb 100644 --- a/services/registration/pin_reset_success +++ b/services/registration/pin_reset_success @@ -1 +1 @@ -Your PIN change request has been successful +Your PIN change request has been successful \ No newline at end of file diff --git a/services/registration/pin_reset_success.vis b/services/registration/pin_reset_success.vis index c942519..9a5aedb 100644 --- a/services/registration/pin_reset_success.vis +++ b/services/registration/pin_reset_success.vis @@ -1,10 +1,8 @@ LOAD confirm_pin_change 0 RELOAD confirm_pin_change -CATCH pin_reset_mismatch flag_pin_mismatch 1 +CATCH pin_reset_mismatch flag_pin_mismatch 1 MOUT back 0 MOUT quit 9 HALT INCMP main 0 INCMP quit 9 - - diff --git a/services/registration/pin_reset_success_swa b/services/registration/pin_reset_success_swa index af69b9f..59580ad 100644 --- a/services/registration/pin_reset_success_swa +++ b/services/registration/pin_reset_success_swa @@ -1 +1 @@ -Ombi lako la kubadili PIN limefanikiwa +Ombi lako la kubadili PIN limefanikiwa \ No newline at end of file diff --git a/services/registration/profile_update_success b/services/registration/profile_update_success index 652942a..d8d5706 100644 --- a/services/registration/profile_update_success +++ b/services/registration/profile_update_success @@ -1 +1 @@ -Profile updated successfully +Profile updated successfully \ No newline at end of file diff --git a/services/registration/profile_update_success_swa b/services/registration/profile_update_success_swa index df0af2c..6b46b3d 100644 --- a/services/registration/profile_update_success_swa +++ b/services/registration/profile_update_success_swa @@ -1 +1 @@ -Ombi la Kuweka wasifu limefanikiwa +Ombi la Kuweka wasifu limefanikiwa \ No newline at end of file diff --git a/services/registration/select_gender.vis b/services/registration/select_gender.vis index 25e53d3..c4e60d1 100644 --- a/services/registration/select_gender.vis +++ b/services/registration/select_gender.vis @@ -9,5 +9,3 @@ HALT RELOAD save_gender INCMP _ 0 INCMP pin_entry * - - diff --git a/test_data.json b/test_data.json index 66d9702..737d40f 100644 --- a/test_data.json +++ b/test_data.json @@ -188,19 +188,19 @@ }, { "input": "1", - "expectedContent": "Enter your old PIN\n\n0:Back" + "expectedContent": "Enter your old PIN\n0:Back" }, { "input": "1234", - "expectedContent": "Enter a new four number pin\n\n0:Back" + "expectedContent": "Enter a new four number pin\n0:Back" }, { "input": "1234", - "expectedContent": "Confirm your new PIN:\n\n0:Back" + "expectedContent": "Confirm your new PIN:\n0:Back" }, { "input": "1234", - "expectedContent": "Your PIN change request has been successful\n\n0:Back\n9:Quit" + "expectedContent": "Your PIN change request has been successful\n0:Back\n9:Quit" }, { "input": "9", @@ -288,7 +288,7 @@ }, { "input": "1234", - "expectedContent": "Profile updated successfully\n\n0:Back\n9:Quit" + "expectedContent": "Profile updated successfully\n0:Back\n9:Quit" }, { "input": "9", @@ -322,7 +322,7 @@ }, { "input": "1234", - "expectedContent": "Profile updated successfully\n\n0:Back\n9:Quit" + "expectedContent": "Profile updated successfully\n0:Back\n9:Quit" }, { "input": "9", @@ -356,7 +356,7 @@ }, { "input": "1234", - "expectedContent": "Profile updated successfully\n\n0:Back\n9:Quit" + "expectedContent": "Profile updated successfully\n0:Back\n9:Quit" }, { "input": "9", @@ -390,7 +390,7 @@ }, { "input": "1234", - "expectedContent": "Profile updated successfully\n\n0:Back\n9:Quit" + "expectedContent": "Profile updated successfully\n0:Back\n9:Quit" }, { "input": "9", @@ -424,7 +424,7 @@ }, { "input": "1234", - "expectedContent": "Profile updated successfully\n\n0:Back\n9:Quit" + "expectedContent": "Profile updated successfully\n0:Back\n9:Quit" }, { "input": "9", @@ -458,7 +458,7 @@ }, { "input": "1234", - "expectedContent": "Profile updated successfully\n\n0:Back\n9:Quit" + "expectedContent": "Profile updated successfully\n0:Back\n9:Quit" }, { "input": "9",