Compare commits

...

16 Commits

Author SHA1 Message Date
e2d5546de1 Merge pull request 'fix-pin-reset-bug' (#26) from fix-pin-reset-bug into master
Some checks failed
release / docker (push) Has been cancelled
Reviewed-on: #26
2025-02-21 10:31:45 +01:00
95089875bf
remove extra spacing 2025-02-21 12:30:28 +03:00
4db25055ad
Added a fix for invalid PIN in PIN reset 2025-02-21 12:29:28 +03:00
e8e6f0e371
Added a fix to only hash valid PINs in SaveOthersTemporaryPin 2025-02-21 11:49:51 +03:00
91c4967efa
check for back 2025-02-21 11:01:42 +03:00
7b1824f18c
go back if account not unlocked 2025-02-21 11:01:31 +03:00
04c3f5ce65
repeat same node on invalid input 2025-02-21 11:01:14 +03:00
e646658f40
repeat same node on invalid input 2025-02-21 10:56:12 +03:00
c4cab444ad
repeat same node on invalid input 2025-02-20 21:26:53 +03:00
b5ade9112e
catch incorrect pin when resetting for others 2025-02-20 21:21:20 +03:00
3b9184e852
check for back 2025-02-20 21:20:41 +03:00
07b85768d1 Merge branch 'master' into fix-pin-reset-bug 2025-02-20 20:00:21 +03:00
c9678df152
reset the PIN using the formattedNumber 2025-02-20 19:59:52 +03:00
c37fee5e54
have the secondarySessionId as a formatted phone number 2025-02-20 19:58:12 +03:00
98b2a31655
remove extra space 2025-02-20 19:56:48 +03:00
d4fcf40b8d Merge pull request 'remove the sessionId from the ctx' (#25) from remove-session-id-from-ctx into master
Reviewed-on: #25
2025-02-20 17:28:54 +01:00
9 changed files with 27 additions and 14 deletions

View File

@ -318,7 +318,7 @@ func (h *MenuHandlers) VerifyNewPin(ctx context.Context, sym string, input []byt
return res, fmt.Errorf("missing session") return res, fmt.Errorf("missing session")
} }
flag_valid_pin, _ := h.flagManager.GetFlag("flag_valid_pin") flag_valid_pin, _ := h.flagManager.GetFlag("flag_valid_pin")
if !h.st.Back() { if string(input) != "0" {
pinInput := string(input) pinInput := string(input)
// Validate that the PIN is a 4-digit number. // Validate that the PIN is a 4-digit number.
if pin.IsValidPIN(pinInput) { if pin.IsValidPIN(pinInput) {
@ -384,6 +384,12 @@ func (h *MenuHandlers) SaveOthersTemporaryPin(ctx context.Context, sym string, i
} }
temporaryPin := string(input) temporaryPin := string(input)
// Validate that the input is a 4-digit number.
if !pin.IsValidPIN(temporaryPin) {
return res, nil
}
// Retrieve the blocked number associated with this session // Retrieve the blocked number associated with this session
blockedNumber, err := store.ReadEntry(ctx, sessionId, storedb.DATA_BLOCKED_NUMBER) blockedNumber, err := store.ReadEntry(ctx, sessionId, storedb.DATA_BLOCKED_NUMBER)
if err != nil { if err != nil {
@ -416,7 +422,7 @@ func (h *MenuHandlers) CheckBlockedNumPinMisMatch(ctx context.Context, sym strin
if !ok { if !ok {
return res, fmt.Errorf("missing session") return res, fmt.Errorf("missing session")
} }
if h.st.Back() { if string(input) == "0" {
res.FlagReset = append(res.FlagReset, flag_pin_mismatch) res.FlagReset = append(res.FlagReset, flag_pin_mismatch)
return res, nil return res, nil
} }
@ -456,7 +462,7 @@ func (h *MenuHandlers) ConfirmPinChange(ctx context.Context, sym string, input [
} }
flag_pin_mismatch, _ := h.flagManager.GetFlag("flag_pin_mismatch") flag_pin_mismatch, _ := h.flagManager.GetFlag("flag_pin_mismatch")
if h.st.Back() { if string(input) == "0" {
res.FlagReset = append(res.FlagReset, flag_pin_mismatch) res.FlagReset = append(res.FlagReset, flag_pin_mismatch)
return res, nil return res, nil
} }
@ -601,16 +607,20 @@ func (h *MenuHandlers) ValidateBlockedNumber(ctx context.Context, sym string, in
return res, fmt.Errorf("missing session") return res, fmt.Errorf("missing session")
} }
if h.st.Back() { if string(input) == "0" {
res.FlagReset = append(res.FlagReset, flag_unregistered_number) res.FlagReset = append(res.FlagReset, flag_unregistered_number)
return res, nil return res, nil
} }
blockedNumber := string(input) blockedNumber := string(input)
_, err = store.ReadEntry(ctx, blockedNumber, storedb.DATA_PUBLIC_KEY) formattedNumber, err := phone.FormatPhoneNumber(blockedNumber)
if !phone.IsValidPhoneNumber(blockedNumber) { if err != nil {
res.FlagSet = append(res.FlagSet, flag_unregistered_number) res.FlagSet = append(res.FlagSet, flag_unregistered_number)
logg.ErrorCtxf(ctx, "Failed to format the phone number: %s", blockedNumber, "error", err)
return res, nil return res, nil
} }
_, err = store.ReadEntry(ctx, formattedNumber, storedb.DATA_PUBLIC_KEY)
if err != nil { if err != nil {
if db.IsNotFound(err) { if db.IsNotFound(err) {
logg.InfoCtxf(ctx, "Invalid or unregistered number") logg.InfoCtxf(ctx, "Invalid or unregistered number")
@ -621,7 +631,7 @@ func (h *MenuHandlers) ValidateBlockedNumber(ctx context.Context, sym string, in
return res, err return res, err
} }
} }
err = store.WriteEntry(ctx, sessionId, storedb.DATA_BLOCKED_NUMBER, []byte(blockedNumber)) err = store.WriteEntry(ctx, sessionId, storedb.DATA_BLOCKED_NUMBER, []byte(formattedNumber))
if err != nil { if err != nil {
return res, nil return res, nil
} }

View File

@ -21,7 +21,7 @@ var (
sessionID string sessionID string
src = rand.NewSource(42) src = rand.NewSource(42)
g = rand.New(src) g = rand.New(src)
secondarySessionId = "0700000000" secondarySessionId = "+254700000000"
) )
var groupTestFile = flag.String("test-file", "group_test.json", "The test file to use for running the group tests") var groupTestFile = flag.String("test-file", "group_test.json", "The test file to use for running the group tests")

View File

@ -1,4 +1,4 @@
CATCH pin_entry flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
RELOAD retrieve_blocked_number RELOAD retrieve_blocked_number
MAP retrieve_blocked_number MAP retrieve_blocked_number
CATCH invalid_others_pin flag_valid_pin 0 CATCH invalid_others_pin flag_valid_pin 0

View File

@ -1,4 +1,4 @@
CATCH no_admin_privilege flag_admin_privilege 0 CATCH no_admin_privilege flag_admin_privilege 0
LOAD reset_account_authorized 0 LOAD reset_account_authorized 0
RELOAD reset_account_authorized RELOAD reset_account_authorized
MOUT back 0 MOUT back 0

View File

@ -1,7 +1,8 @@
RELOAD reset_incorrect RELOAD reset_allow_update
MOUT back 0 MOUT back 0
HALT HALT
INCMP _ 0 INCMP _ 0
RELOAD authorize_account RELOAD authorize_account
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
CATCH _ flag_allow_update 0
INCMP new_pin * INCMP new_pin *

View File

@ -3,3 +3,4 @@ MOUT quit 9
HALT HALT
INCMP _ 1 INCMP _ 1
INCMP quit 9 INCMP quit 9
INCMP . *

View File

@ -3,12 +3,12 @@ LOAD authorize_account 5
LOAD reset_allow_update 4 LOAD reset_allow_update 4
LOAD verify_new_pin 2 LOAD verify_new_pin 2
LOAD save_temporary_pin 1 LOAD save_temporary_pin 1
LOAD reset_incorrect 0 LOAD reset_incorrect 0
MOUT change_pin 1 MOUT change_pin 1
MOUT reset_pin 2 MOUT reset_pin 2
MOUT back 0 MOUT back 0
HALT HALT
INCMP _ 0 INCMP _ 0
INCMP old_pin 1 INCMP old_pin 1
INCMP enter_other_number 2 INCMP enter_other_number 2
INCMP . * INCMP . *

View File

@ -3,4 +3,4 @@ MOUT quit 9
HALT HALT
INCMP _ 1 INCMP _ 1
INCMP quit 9 INCMP quit 9
INCMP . *

View File

@ -3,3 +3,4 @@ MOUT quit 9
HALT HALT
INCMP main 0 INCMP main 0
INCMP quit 9 INCMP quit 9
INCMP . *