validate PIN using the set AccountPIN

This commit is contained in:
Alfred Kamanda 2024-08-23 16:01:13 +03:00
parent a508f06583
commit 460e951584
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703

View File

@ -362,8 +362,21 @@ func (fsd *fsData) checkIdentifier(ctx context.Context, sym string, input []byte
func (fsd *fsData) unLock(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
pin := string(input)
if len(input) > 0 {
if pin == "0000" {
fp := fsd.path + "_data"
jsonData, err := os.ReadFile(fp)
if err != nil {
return res, err
}
var accountData map[string]string
err = json.Unmarshal(jsonData, &accountData)
if err != nil {
return res, err
}
if len(input) > 1 {
if pin != accountData["AccountPIN"] {
res.FlagSet = append(res.FlagSet, USERFLAG_INCORRECTPIN)
res.FlagReset = append(res.FlagReset, USERFLAG_ACCOUNT_UNLOCKED)
return res, nil