Ensure that the user sets a PIN before proceeding to main

This commit is contained in:
2024-08-27 15:41:53 +03:00
parent 2a5f7517f4
commit 1d578209fc
6 changed files with 13 additions and 3 deletions

View File

@@ -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}
}