Skip to content

UserManagementView: Determine current user via /api/user - #255

Open
FideliusFalcon wants to merge 1 commit into
supergeorg:mainfrom
FideliusFalcon:fix/current-user-marker-without-system-config
Open

UserManagementView: Determine current user via /api/user#255
FideliusFalcon wants to merge 1 commit into
supergeorg:mainfrom
FideliusFalcon:fix/current-user-marker-without-system-config

Conversation

@FideliusFalcon

Copy link
Copy Markdown

isCurrentUser in UserManagementView was derived from USER_USERNAME in /api/system/config. Grocy 4.7.0 removed that key (grocy commit b6c07a51), and making userUsername optional in dc3bd72 fixed the decoding error but left the value permanently nil against 4.7.0+ servers.

isCurrentUser is therefore always false, which disables the guard in UserRowActionsView:

.disabled(isCurrentUser)

The delete button is live on your own account, and grocy's UsersApiController::DeleteUser has no server-side self-deletion check.

This uses grocyVM.currentUser, populated from /api/user, and compares by id — the same approach TasksView and ChoresView already use. /api/user is present in both 4.6.0 and current grocy, so behaviour is unchanged on older servers. .system_config is no longer requested by this view, and the now-unused systemConfigList query is removed.

Built for iOS (Xcode 26.6, iOS 26.5 simulator SDK): BUILD SUCCEEDED. Not verified at runtime.

USER_USERNAME was removed from /api/system/config in Grocy 4.7.0, so
userUsername is nil against newer servers and no row is ever treated as
the current user. This disables the safeguard that prevents deleting
your own account. Use the already fetched currentUser instead, matching
how TasksView and ChoresView identify the current user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant