-
Notifications
You must be signed in to change notification settings - Fork 524
Limit the lenght of User Name #2764
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
120f200
Limit the lenght of User Name
HunsupJung 93387e5
Merge branch 'main' into fix/limit-length-user-name
HunsupJung df7b173
Rename the variable and reduce code
HunsupJung 2a6eaf4
Merge branch 'main' into fix/limit-length-user-name
HunsupJung bf23f18
Modify test units
HunsupJung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| From f19da9191362d70a020ab6852233eb327c19f906 Mon Sep 17 00:00:00 2001 | ||
| From: Hunsup Jung <hunsup.jung@samsung.com> | ||
| Date: Sat, 7 Mar 2026 15:36:45 +0900 | ||
| Subject: [PATCH] Rename the variable and reduce code | ||
|
|
||
| Signed-off-by: Hunsup Jung <hunsup.jung@samsung.com> | ||
| --- | ||
| .../matter-lock/src/new-matter-lock/init.lua | 25 +++++++++---------- | ||
| 1 file changed, 12 insertions(+), 13 deletions(-) | ||
|
|
||
| diff --git a/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua b/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua | ||
| index d9b9c9f6..37a9493a 100644 | ||
| --- a/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua | ||
| +++ b/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua | ||
| @@ -29,7 +29,8 @@ local PowerSource = clusters.PowerSource | ||
|
|
||
| local INITIAL_CREDENTIAL_INDEX = 1 | ||
| local ALL_INDEX = 0xFFFE | ||
| -local NAME_MAX_L = 10 | ||
| +-- maximum as defined by the Matter specification | ||
| +local MAX_USER_NAME_LENGTH = 10 | ||
| local MIN_EPOCH_S = 0 | ||
| local MAX_EPOCH_S = 0xffffffff | ||
| local THIRTY_YEARS_S = 946684800 -- 1970-01-01T00:00:00 ~ 2000-01-01T00:00:00 | ||
| @@ -1274,10 +1275,7 @@ local function handle_update_user(driver, device, command) | ||
| local cmdName = "updateUser" | ||
| local userIdx = command.args.userIndex | ||
| local userName = command.args.userName | ||
| - local userNameMatter = userName | ||
| - if #userNameMatter > NAME_MAX_L then | ||
| - userNameMatter = string.sub(userNameMatter, 1, NAME_MAX_L) | ||
| - end | ||
| + local userNameMatter = string.sub(userName, 1, MAX_USER_NAME_LENGTH) | ||
| local userType = command.args.userType | ||
| local userTypeMatter = DoorLock.types.UserTypeEnum.UNRESTRICTED_USER | ||
| if userType == "guest" then | ||
| @@ -1307,7 +1305,7 @@ local function handle_update_user(driver, device, command) | ||
| device:send( | ||
| DoorLock.server.commands.SetUser( | ||
| device, ep, | ||
| - DoorLock.types.DataOperationTypeEnum.MODIFY, -- Operation Type: Add(0), Modify(2) | ||
| + DoorLock.types.DataOperationTypeEnum.MODIFY, | ||
| userIdx, | ||
| userNameMatter, | ||
| nil, -- Unique ID | ||
| @@ -1355,6 +1353,7 @@ local function get_user_response_handler(driver, device, ib, response) | ||
| -- Found available user index | ||
| if status == nil or status == DoorLock.types.UserStatusEnum.AVAILABLE then | ||
| local userName = device:get_field(lock_utils.USER_NAME) | ||
| + local userNameMatter = string.sub(userName, 1, MAX_USER_NAME_LENGTH) | ||
| local userType = device:get_field(lock_utils.USER_TYPE) | ||
| local userTypeMatter = DoorLock.types.UserTypeEnum.UNRESTRICTED_USER | ||
| if userType == "guest" then | ||
| @@ -1368,13 +1367,13 @@ local function get_user_response_handler(driver, device, ib, response) | ||
| device:send( | ||
| DoorLock.server.commands.SetUser( | ||
| device, ep, | ||
| - DoorLock.types.DataOperationTypeEnum.ADD, -- Operation Type: Add(0), Modify(2) | ||
| - userIdx, -- User Index | ||
| - userName, -- User Name | ||
| - nil, -- Unique ID | ||
| - nil, -- User Status | ||
| - userTypeMatter, -- User Type | ||
| - nil -- Credential Rule | ||
| + DoorLock.types.DataOperationTypeEnum.ADD, | ||
| + userIdx, | ||
| + userNameMatter, | ||
| + nil, -- Unique ID | ||
| + nil, -- User Status | ||
| + userTypeMatter, | ||
| + nil -- Credential Rule | ||
| ) | ||
| ) | ||
| elseif userIdx >= maxUser then -- There's no available user index | ||
| -- | ||
| 2.39.5 (Apple Git-154) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.