Merge pull request 'fix-pin-reset-bug' (#26) from fix-pin-reset-bug into master
Some checks failed
release / docker (push) Has been cancelled
Some checks failed
release / docker (push) Has been cancelled
Reviewed-on: #26
This commit is contained in:
commit
e2d5546de1
@ -318,7 +318,7 @@ func (h *MenuHandlers) VerifyNewPin(ctx context.Context, sym string, input []byt
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
flag_valid_pin, _ := h.flagManager.GetFlag("flag_valid_pin")
|
||||
if !h.st.Back() {
|
||||
if string(input) != "0" {
|
||||
pinInput := string(input)
|
||||
// Validate that the PIN is a 4-digit number.
|
||||
if pin.IsValidPIN(pinInput) {
|
||||
@ -384,6 +384,12 @@ func (h *MenuHandlers) SaveOthersTemporaryPin(ctx context.Context, sym string, i
|
||||
}
|
||||
|
||||
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
|
||||
blockedNumber, err := store.ReadEntry(ctx, sessionId, storedb.DATA_BLOCKED_NUMBER)
|
||||
if err != nil {
|
||||
@ -416,7 +422,7 @@ func (h *MenuHandlers) CheckBlockedNumPinMisMatch(ctx context.Context, sym strin
|
||||
if !ok {
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
if h.st.Back() {
|
||||
if string(input) == "0" {
|
||||
res.FlagReset = append(res.FlagReset, flag_pin_mismatch)
|
||||
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")
|
||||
|
||||
if h.st.Back() {
|
||||
if string(input) == "0" {
|
||||
res.FlagReset = append(res.FlagReset, flag_pin_mismatch)
|
||||
return res, nil
|
||||
}
|
||||
@ -601,16 +607,20 @@ func (h *MenuHandlers) ValidateBlockedNumber(ctx context.Context, sym string, in
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
|
||||
if h.st.Back() {
|
||||
if string(input) == "0" {
|
||||
res.FlagReset = append(res.FlagReset, flag_unregistered_number)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
blockedNumber := string(input)
|
||||
_, err = store.ReadEntry(ctx, blockedNumber, storedb.DATA_PUBLIC_KEY)
|
||||
if !phone.IsValidPhoneNumber(blockedNumber) {
|
||||
formattedNumber, err := phone.FormatPhoneNumber(blockedNumber)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_unregistered_number)
|
||||
logg.ErrorCtxf(ctx, "Failed to format the phone number: %s", blockedNumber, "error", err)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
_, err = store.ReadEntry(ctx, formattedNumber, storedb.DATA_PUBLIC_KEY)
|
||||
if err != nil {
|
||||
if db.IsNotFound(err) {
|
||||
logg.InfoCtxf(ctx, "Invalid or unregistered number")
|
||||
@ -621,7 +631,7 @@ func (h *MenuHandlers) ValidateBlockedNumber(ctx context.Context, sym string, in
|
||||
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 {
|
||||
return res, nil
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ var (
|
||||
sessionID string
|
||||
src = rand.NewSource(42)
|
||||
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")
|
||||
|
@ -1,4 +1,4 @@
|
||||
CATCH pin_entry flag_incorrect_pin 1
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
RELOAD retrieve_blocked_number
|
||||
MAP retrieve_blocked_number
|
||||
CATCH invalid_others_pin flag_valid_pin 0
|
||||
|
@ -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
|
||||
RELOAD reset_account_authorized
|
||||
MOUT back 0
|
||||
|
@ -1,7 +1,8 @@
|
||||
RELOAD reset_incorrect
|
||||
RELOAD reset_allow_update
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP _ 0
|
||||
RELOAD authorize_account
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH _ flag_allow_update 0
|
||||
INCMP new_pin *
|
||||
|
@ -3,3 +3,4 @@ MOUT quit 9
|
||||
HALT
|
||||
INCMP _ 1
|
||||
INCMP quit 9
|
||||
INCMP . *
|
||||
|
@ -3,12 +3,12 @@ LOAD authorize_account 5
|
||||
LOAD reset_allow_update 4
|
||||
LOAD verify_new_pin 2
|
||||
LOAD save_temporary_pin 1
|
||||
LOAD reset_incorrect 0
|
||||
LOAD reset_incorrect 0
|
||||
MOUT change_pin 1
|
||||
MOUT reset_pin 2
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP _ 0
|
||||
INCMP old_pin 1
|
||||
INCMP old_pin 1
|
||||
INCMP enter_other_number 2
|
||||
INCMP . *
|
||||
|
@ -3,4 +3,4 @@ MOUT quit 9
|
||||
HALT
|
||||
INCMP _ 1
|
||||
INCMP quit 9
|
||||
|
||||
INCMP . *
|
||||
|
@ -3,3 +3,4 @@ MOUT quit 9
|
||||
HALT
|
||||
INCMP main 0
|
||||
INCMP quit 9
|
||||
INCMP . *
|
||||
|
Loading…
Reference in New Issue
Block a user