forked from urdt/ussd
Ensure that the user sets a PIN before proceeding to main
This commit is contained in:
@@ -61,6 +61,13 @@ func (h *Handlers) CreateAccount(ctx context.Context, sym string, input []byte)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// if an account exists, set the flag and return
|
||||
existingAccountData, err := h.accountFileHandler.ReadAccountData()
|
||||
if existingAccountData != nil {
|
||||
res.FlagSet = append(res.FlagSet, models.USERFLAG_ACCOUNT_CREATED)
|
||||
return res, err
|
||||
}
|
||||
|
||||
accountResp, err := server.CreateAccount()
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, models.USERFLAG_ACCOUNT_CREATION_FAILED)
|
||||
@@ -119,6 +126,7 @@ func (h *Handlers) VerifyPin(ctx context.Context, sym string, input []byte) (res
|
||||
if bytes.Equal(input, []byte(accountData["AccountPIN"])) {
|
||||
res.FlagSet = []uint32{models.USERFLAG_VALIDPIN}
|
||||
res.FlagReset = []uint32{models.USERFLAG_PINMISMATCH}
|
||||
res.FlagSet = append(res.FlagSet, models.USERFLAG_PIN_SET)
|
||||
} else {
|
||||
res.FlagSet = []uint32{models.USERFLAG_PINMISMATCH}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ const (
|
||||
USERFLAG_INCORRECTPIN
|
||||
USERFLAG_UNLOCKFORUPDATE
|
||||
USERFLAG_INVALID_AMOUNT
|
||||
USERFLAG_QUERYPIN
|
||||
USERFLAG_PIN_SET
|
||||
USERFLAG_VALIDPIN
|
||||
USERFLAG_PINMISMATCH
|
||||
USERFLAG_INCORRECTDATEFORMAT
|
||||
|
||||
Reference in New Issue
Block a user