Bug 495494

Summary: It's possible to delete a logged-in user with no warnings
Product: [Applications] systemsettings Reporter: Nate Graham <nate>
Component: kcm_usersAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: kde, uhhadd
Priority: NOR Keywords: usability
Version First Reported In: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.4.0
Sentry Crash Report:

Description Nate Graham 2024-10-28 17:12:11 UTC
STEPS TO REPRODUCE
1. System Settings > Users > Create a new user account
2. Kickoff > Leave > Switch User > Log into the new user account
3. Kickoff > Leave > Switch User > Log back into your original user account
4. System Settings > Users > Delete the new user account while it's still logged in

OBSERVED RESULT
There are no warnings or errors; you can delete the account while it's still logged in!

EXPECTED RESULT
At the very least, a warning about this.

ADDITIONAL INFORMATION
If I try to switch user to the still-logged-in-but-not-deleted user account, it fails to accept the password.
Comment 1 Nate Graham 2025-03-14 18:15:02 UTC
I don't see a thing in AccountsService's DBus interface for this, but maybe we could use get enough data about users on the system from the LoginHistory method. It would probably be easier to parse the output of `users` though.
Comment 2 Bug Janitor Service 2025-03-14 22:44:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5320
Comment 3 Nate Graham 2025-04-22 21:20:50 UTC
Git commit 9abfdd2640bc83608e347e2180cd30198001cb64 by Nate Graham.
Committed on 22/04/2025 at 20:48.
Pushed by ngraham into branch 'master'.

kcm/users: refine "deleting logged-in user" UX

Right now there are two problems:
1. Deleting a logged-in user shows no warning about this.
2. Asking to delete the files of a logged-in user fails silently
   (AccountsService simply won't do it).

This commit solves both problems: now the user sees a warning dialog
when they try to delete another logged-in user, and it also prevents
them from trying to delete a logged-in user's files, instead redirecting
them to just delete the account but not the files.

To achieve this, I needed to change what the `loggedIn` property does,
because previously it was inaccurate, returning whether the queried user
is the currently logged-in user. Now it returns whether the quaried user
is logged in, and I added a new `isMe` property to hold whether the
queried user is the currently logged-in user.
FIXED-IN: 6.4.0

M  +1    -0    kcms/users/src/CMakeLists.txt
M  +40   -6    kcms/users/src/ui/UserDetailsPage.qml
M  +1    -1    kcms/users/src/ui/main.qml
M  +22   -4    kcms/users/src/user.cpp
M  +6    -1    kcms/users/src/user.h
M  +7    -4    kcms/users/src/usermodel.cpp
M  +2    -1    kcms/users/src/usermodel.h

https://invent.kde.org/plasma/plasma-workspace/-/commit/9abfdd2640bc83608e347e2180cd30198001cb64