Compare commits
4 Commits
c359d99075
...
efdb52bccd
Author | SHA1 | Date | |
---|---|---|---|
efdb52bccd | |||
2ff9fed3c5 | |||
477b4cf8f6 | |||
ed6651697a |
@ -6,10 +6,13 @@ import (
|
|||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Define the regex pattern as a constant
|
|
||||||
const (
|
const (
|
||||||
pinPattern = `^\d{4}$`
|
// Define the regex pattern as a constant
|
||||||
|
pinPattern = `^\d{4}$`
|
||||||
|
|
||||||
|
//Allowed incorrect PIN attempts
|
||||||
AllowedPINAttempts = uint8(3)
|
AllowedPINAttempts = uint8(3)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// checks whether the given input is a 4 digit number
|
// checks whether the given input is a 4 digit number
|
||||||
|
@ -747,7 +747,7 @@ func (h *Handlers) Authorize(ctx context.Context, sym string, input []byte) (res
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err := h.countIncorrectPINAttempts(ctx, sessionId)
|
err := h.incrementIncorrectPINAttempts(ctx, sessionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@ -884,7 +884,7 @@ func (h *Handlers) ShowBlockedAccount(ctx context.Context, sym string, input []b
|
|||||||
code := codeFromCtx(ctx)
|
code := codeFromCtx(ctx)
|
||||||
l := gotext.NewLocale(translationDir, code)
|
l := gotext.NewLocale(translationDir, code)
|
||||||
l.AddDomain("default")
|
l.AddDomain("default")
|
||||||
res.Content = l.Get("Your account has been locked.For help on how to unblock your account,contact support at: 0757628885")
|
res.Content = l.Get("Your account has been locked.For help on how to unblock your account, contact support at: 0757628885")
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2124,8 +2124,8 @@ func (h *Handlers) UpdateAllProfileItems(ctx context.Context, sym string, input
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// countIncorrectPINAttempts keeps track of the number of incorrect PIN attempts
|
// incrementIncorrectPINAttempts keeps track of the number of incorrect PIN attempts
|
||||||
func (h *Handlers) countIncorrectPINAttempts(ctx context.Context, sessionId string) error {
|
func (h *Handlers) incrementIncorrectPINAttempts(ctx context.Context, sessionId string) error {
|
||||||
var pinAttemptsCount uint8
|
var pinAttemptsCount uint8
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
|
|
||||||
@ -2163,8 +2163,8 @@ func (h *Handlers) resetIncorrectPINAttempts(ctx context.Context, sessionId stri
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
remainingPINAttempts, _ := strconv.ParseUint(string(currentWrongPinAttempts), 0, 64)
|
currentWrongPinAttemptsCount, _ := strconv.ParseUint(string(currentWrongPinAttempts), 0, 64)
|
||||||
if remainingPINAttempts <= uint64(common.AllowedPINAttempts) {
|
if currentWrongPinAttemptsCount <= uint64(common.AllowedPINAttempts) {
|
||||||
err = store.WriteEntry(ctx, sessionId, common.DATA_INCORRECT_PIN_ATTEMPTS, []byte(string("0")))
|
err = store.WriteEntry(ctx, sessionId, common.DATA_INCORRECT_PIN_ATTEMPTS, []byte(string("0")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "failed to reset incorrect PIN attempts ", "key", common.DATA_INCORRECT_PIN_ATTEMPTS, "value", common.AllowedPINAttempts, "error", err)
|
logg.ErrorCtxf(ctx, "failed to reset incorrect PIN attempts ", "key", common.DATA_INCORRECT_PIN_ATTEMPTS, "value", common.AllowedPINAttempts, "error", err)
|
||||||
|
@ -2247,7 +2247,7 @@ func TestCountIncorrectPINAttempts(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf(err.Error())
|
t.Logf(err.Error())
|
||||||
}
|
}
|
||||||
err = h.countIncorrectPINAttempts(ctx, sessionId)
|
err = h.incrementIncorrectPINAttempts(ctx, sessionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf(err.Error())
|
t.Logf(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "1235",
|
"input": "1235",
|
||||||
"expectedContent": "Incorrect PIN.You have: 2 remaining attempt(s).\n1:Retry\n9:Quit"
|
"expectedContent": "Incorrect PIN. You have: 2 remaining attempt(s).\n1:Retry\n9:Quit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "1",
|
"input": "1",
|
||||||
@ -95,7 +95,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "1235",
|
"input": "1235",
|
||||||
"expectedContent": "Incorrect PIN.You have: 2 remaining attempt(s).\n1:Retry\n9:Quit"
|
"expectedContent": "Incorrect PIN. You have: 2 remaining attempt(s).\n1:Retry\n9:Quit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "1",
|
"input": "1",
|
||||||
@ -140,7 +140,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "1235",
|
"input": "1235",
|
||||||
"expectedContent": "Incorrect PIN.You have: 2 remaining attempt(s).\n1:Retry\n9:Quit"
|
"expectedContent": "Incorrect PIN. You have: 2 remaining attempt(s).\n1:Retry\n9:Quit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "1",
|
"input": "1",
|
||||||
|
@ -1 +1 @@
|
|||||||
Incorrect PIN.You have: {{.reset_incorrect}} remaining attempt(s).
|
Incorrect PIN. You have: {{.reset_incorrect}} remaining attempt(s).
|
@ -1 +1 @@
|
|||||||
PIN ulioeka sio sahihi,una majaribio: {{.reset_incorrect}} yaliyobaki
|
PIN ulioeka sio sahihi, una majaribio: {{.reset_incorrect}} yaliyobaki
|
@ -10,7 +10,7 @@ msgstr "Asante kwa kutumia huduma ya Sarafu. Kwaheri!"
|
|||||||
msgid "For more help, please call: 0757628885"
|
msgid "For more help, please call: 0757628885"
|
||||||
msgstr "Kwa usaidizi zaidi, piga: 0757628885"
|
msgstr "Kwa usaidizi zaidi, piga: 0757628885"
|
||||||
|
|
||||||
msgid "Your account has been locked.For help on how to unblock your account,contact support at: 0757628885"
|
msgid "Your account has been locked.For help on how to unblock your account, contact support at: 0757628885"
|
||||||
msgstr "Akaunti yako imefungwa.Kwa usaidizi wa jinsi ya kufungua akaunti yako, wasiliana na usaidizi kwa: 0757628885"
|
msgstr "Akaunti yako imefungwa.Kwa usaidizi wa jinsi ya kufungua akaunti yako, wasiliana na usaidizi kwa: 0757628885"
|
||||||
|
|
||||||
msgid "Balance: %s\n"
|
msgid "Balance: %s\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user