Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset the wrong code retry attempts if a valid credential is presented #25536

Merged
6 changes: 3 additions & 3 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ bool DoorLockServer::SetLockState(chip::EndpointId endpointId, DlLockState newLo
SendLockOperationEvent(endpointId, opType, opSource, OperationErrorEnum::kUnspecified, userIndex, Nullable<chip::FabricIndex>(),
Nullable<chip::NodeId>(), credentials, success);

// Reset code wrong entry attempts (in case there were any incorrect wrong code retries prior) since lock/unlock was a success
// and a valid credential was presented
// Reset wrong entry attempts (in case there were any incorrect wrong credentials presented before) if lock/unlock was a success
nivi-apple marked this conversation as resolved.
Show resolved Hide resolved
// and a valid credential was presented.
if (success && !credentials.IsNull() && !(credentials.Value().empty()))
{
ResetWrongCodeEntryAttempts(endpointId);
nivi-apple marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -3374,7 +3374,7 @@ bool DoorLockServer::HandleRemoteLockOperation(chip::app::CommandHandler * comma
}

// Reset the wrong code retry attempts if a valid credential is presented during lock/unlock
if ((opType == LockOperationTypeEnum::kUnlock || opType == LockOperationTypeEnum::kLock) && success && pinCode.HasValue())
if (success && pinCode.HasValue())
{
ResetWrongCodeEntryAttempts(endpoint);
nivi-apple marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
13 changes: 5 additions & 8 deletions src/app/clusters/door-lock-server/door-lock-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ class DoorLockServer
/**
* @brief Handles a wrong code entry attempt for the endpoint. If the number of wrong entry attempts exceeds the max limit,
* engage lockout. Otherwise increment the number of incorrect attempts by 1. This is handled automatically for
* remote operations - lock and unlock . Any app that uses SetLockState or sends lock/unlock events via
* SendLockOperationEvent has to handle tracking of wrong retry attempts and needs to call this API to update the wrong entry
* attempt count or engage lockoutif retry limit is exceeded.
* remote operations - lock and unlock. Applications are responsible for calling it for non-remote incorrect credential presentation attempts.
*
* @param endpointId
*/
Expand Down Expand Up @@ -193,11 +191,10 @@ class DoorLockServer

static void DoorLockOnAutoRelockCallback(chip::System::Layer *, void * callbackContext);
/**
* @brief Resets the wrong code entry attempts to 0 for the endpoint. This API is called from HandleRemoteLockOperation
* to reset the count if we have an lock/unlock remote operation with valid credential automatically. An app that
* calls SetLockState also will have this done automatically on successful unlock operation using valid credential.
* Any app that sends unlock events via SendLockOperationEvent has to handle resetting the wrong retry count by
* calling this API.
* @brief Resets the wrong code entry attempts to 0 for the endpoint. This is done automatically when a
* remote lock operation with credentials succeeds, or when SetLockState is called with a non-empty credentials list.
* Applications that call the two-argument version of SetLockState and handle sending the relevant operation events
* themselves or via SendLockOperationEvent are responsible for calling this API when a valid credential is presented.
*
* @param endpointId
*/
Expand Down