diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index 13d1315..1c28217 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -273,18 +273,29 @@ func (h *MenuHandlers) ResetValidPin(ctx context.Context, sym string, input []by return res, nil } -// CheckBlockedStatus resets the account blocked flag if the PIN attempts have been reset by an admin. +// CheckBlockedStatus: +// 1. Checks whether the DATA_SELF_PIN_RESET is 1 and sets the flag_account_pin_reset +// 2. resets the account blocked flag if the PIN attempts have been reset by an admin. func (h *MenuHandlers) CheckBlockedStatus(ctx context.Context, sym string, input []byte) (resource.Result, error) { var res resource.Result store := h.userdataStore flag_account_blocked, _ := h.flagManager.GetFlag("flag_account_blocked") + flag_account_pin_reset, _ := h.flagManager.GetFlag("flag_account_pin_reset") sessionId, ok := ctx.Value("SessionId").(string) if !ok { return res, fmt.Errorf("missing session") } + selfPinReset, err := store.ReadEntry(ctx, sessionId, storedb.DATA_SELF_PIN_RESET) + if err == nil { + pinResetValue, _ := strconv.ParseUint(string(selfPinReset), 0, 64) + if pinResetValue == 1 { + res.FlagSet = append(res.FlagSet, flag_account_pin_reset) + } + } + currentWrongPinAttempts, err := store.ReadEntry(ctx, sessionId, storedb.DATA_INCORRECT_PIN_ATTEMPTS) if err != nil { if !db.IsNotFound(err) { @@ -293,7 +304,6 @@ func (h *MenuHandlers) CheckBlockedStatus(ctx context.Context, sym string, input } pinAttemptsValue, _ := strconv.ParseUint(string(currentWrongPinAttempts), 0, 64) - if pinAttemptsValue == 0 { res.FlagReset = append(res.FlagReset, flag_account_blocked) return res, nil @@ -630,6 +640,7 @@ func (h *MenuHandlers) ResetUnregisteredNumber(ctx context.Context, sym string, // ValidateBlockedNumber performs validation of phone numbers, specifically for blocked numbers in the system. // It checks phone number format and verifies registration status. +// If valid, it sets DATA_SELF_PIN_RESET as 1 on the account func (h *MenuHandlers) ValidateBlockedNumber(ctx context.Context, sym string, input []byte) (resource.Result, error) { var res resource.Result var err error @@ -665,10 +676,18 @@ func (h *MenuHandlers) ValidateBlockedNumber(ctx context.Context, sym string, in return res, err } } + err = store.WriteEntry(ctx, sessionId, storedb.DATA_BLOCKED_NUMBER, []byte(formattedNumber)) if err != nil { return res, nil } + + // set the DATA_SELF_PIN_RESET for the account + err = store.WriteEntry(ctx, formattedNumber, storedb.DATA_SELF_PIN_RESET, []byte("1")) + if err != nil { + return res, nil + } + return res, nil } diff --git a/services/registration/pp.csv b/services/registration/pp.csv index e34de5d..dec5b42 100644 --- a/services/registration/pp.csv +++ b/services/registration/pp.csv @@ -31,3 +31,4 @@ flag,flag_back_set,37,this is set when it is a back navigation flag,flag_account_blocked,38,this is set when an account has been blocked after the allowed incorrect PIN attempts have been exceeded flag,flag_invalid_pin,39,this is set when the given PIN is invalid(is less than or more than 4 digits) flag,flag_alias_set,40,this is set when an account alias has been assigned to a user +flag,flag_account_pin_reset,41,this is set on an account when an admin triggers a PIN reset for them