From 5312649622b13357dfb3e0834d0ebfb5a3b9889c Mon Sep 17 00:00:00 2001 From: Joshua Villasenor Date: Thu, 22 Dec 2022 14:20:34 -0800 Subject: [PATCH] Resolve issue when adding same index with different credential type. (#24156) --- src/app/clusters/door-lock-server/door-lock-server.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index a3c75c4818ff9c..86f6b10fe7b7d4 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -2085,8 +2085,11 @@ DlStatus DoorLockServer::addCredentialToUser(chip::EndpointId endpointId, chip:: for (size_t i = 0; i < user.credentials.size(); ++i) { - // appclusters, 5.2.4.40: user should not be already associated with given credentialIndex - if (user.credentials.data()[i].CredentialIndex == credential.CredentialIndex) + // appclusters, 5.2.4.40: CredentialIndex in CredentialStruct provided SHALL be for an available credential slot. + // appclusters, 5.6.3.2: This is the index of the specific credential used to authorize + // the lock operation in the list of credentials identified by CredentialType + if (user.credentials.data()[i].CredentialIndex == credential.CredentialIndex && + user.credentials.data()[i].CredentialType == credential.CredentialType) { emberAfDoorLockClusterPrintln( "[AddCredentialToUser] Unable to add credential to user: credential with this index is already associated "