Compare commits
No commits in common. "0a97f610a47746c25cc7748ebbf29937e3bc11a2" and "d0ad6395b5670501b543e61e2a5ef2c8c5acf2ca" have entirely different histories.
0a97f610a4
...
d0ad6395b5
@ -35,12 +35,6 @@ var (
|
||||
backOption = []byte("0")
|
||||
)
|
||||
|
||||
// Define the regex patterns as constants
|
||||
const (
|
||||
phoneRegex = `(\(\d{3}\)\s?|\d{3}[-.\s]?)?\d{3}[-.\s]?\d{4}`
|
||||
pinPattern = `^\d{4}$`
|
||||
)
|
||||
|
||||
// FlagManager handles centralized flag management
|
||||
type FlagManager struct {
|
||||
parser *asm.FlagParser
|
||||
@ -88,17 +82,15 @@ func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db, accountService s
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// Define the regex pattern as a constant
|
||||
const pinPattern = `^\d{4}$`
|
||||
|
||||
// isValidPIN checks whether the given input is a 4 digit number
|
||||
func isValidPIN(pin string) bool {
|
||||
match, _ := regexp.MatchString(pinPattern, pin)
|
||||
return match
|
||||
}
|
||||
|
||||
func isValidPhoneNumber(phonenumber string) bool {
|
||||
match, _ := regexp.MatchString(phoneRegex, phonenumber)
|
||||
return match
|
||||
}
|
||||
|
||||
func (h *Handlers) WithPersister(pe *persist.Persister) *Handlers {
|
||||
if h.pe != nil {
|
||||
panic("persister already set")
|
||||
@ -263,6 +255,7 @@ func (h *Handlers) SaveTemporaryPin(ctx context.Context, sym string, input []byt
|
||||
}
|
||||
|
||||
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
||||
|
||||
accountPIN := string(input)
|
||||
|
||||
// Validate that the PIN is a 4-digit number
|
||||
@ -775,9 +768,6 @@ func (h *Handlers) ValidateBlockedNumber(ctx context.Context, sym string, input
|
||||
}
|
||||
blockedNumber := string(input)
|
||||
_, err = store.ReadEntry(ctx, blockedNumber, utils.DATA_PUBLIC_KEY)
|
||||
if !isValidPhoneNumber(blockedNumber) {
|
||||
return res, nil
|
||||
}
|
||||
if err != nil {
|
||||
if db.IsNotFound(err) {
|
||||
logg.Printf(logging.LVL_INFO, "Invalid or unregistered number")
|
||||
|
@ -1,10 +1,9 @@
|
||||
CATCH no_admin_privilege flag_admin_privilege 0
|
||||
LOAD reset_account_authorized 0
|
||||
LOAD reset_account_authorized 6
|
||||
RELOAD reset_account_authorized
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP _ 0
|
||||
LOAD validate_blocked_number 20
|
||||
LOAD validate_blocked_number 0
|
||||
RELOAD validate_blocked_number
|
||||
CATCH unregistered_number flag_unregistered_number 1
|
||||
INCMP pin_management 0
|
||||
INCMP enter_others_new_pin *
|
||||
|
@ -1,3 +1,4 @@
|
||||
CATCH unregistered_number flag_unregistered_number 1
|
||||
LOAD retrieve_blocked_number 0
|
||||
MAP retrieve_blocked_number
|
||||
MOUT back 0
|
||||
|
@ -3,5 +3,5 @@ RELOAD reset_unregistered_number
|
||||
MOUT retry 1
|
||||
MOUT quit 9
|
||||
HALT
|
||||
INCMP _ 1
|
||||
INCMP enter_other_number 1
|
||||
INCMP quit 9
|
||||
|
Loading…
Reference in New Issue
Block a user