feat: convert regular accounts to guests#1619
Open
ernolf wants to merge 2 commits into
Open
Conversation
- add "Convert to guest account" for regular, never-logged-in database accounts (admin … menu action + OCS endpoint), keeping the login name and password - add ConversionService for the transactional users -> guests_users move; extract GuestManager::setGuestQuota so converted accounts get the default guest quota - allow a free-form guest login name via `occ guests:add --uid` instead of deriving the user ID from the email address - loosen the guests backend user-id guard to accept any non-empty id Closes #1153 Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>
Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an admin action to convert a regular account into a guest account, and lets guests have a free-form login name instead of one derived from their email.
Closes #1153
Closes #333
Related #1479
Convert accounts to guests
Create a user (just for testing):
$ occ user:info karltest - user_id: karltest - display_name: Karl Test - email: - cloud_id: karltest@global-social.net - enabled: true - groups: - quota: none - storage: - free: 1184627609600 - used: 0 - total: 1184627609600 - relative: 0 - quota: -3 - first_seen: never - last_seen: never - user_directory: /nc/dat/data/karltest - backend: DatabaseIn Administration settings → Users, the account's
…menu gains Convert to guest account.A confirmation dialog explains the effect: the account keeps its login name and password but becomes a limited guest, restricted to the apps allowed for guests, and receives the default guest quota. The conversion cannot be undone automatically.
It is only possible for accounts that use the database backend, are not already a guest, and have never logged in (enforced in the UI and in the OCS endpoint).
After conversion the account's backend is Guests:
and it logs in with the same password:
It then appears in the guests list:
Use case: self-registration
A typical use case is self-registration through the registration app with "Require administrator approval" enabled: those accounts are created disabled and never logged in, so an administrator can downgrade them to guests instead of enabling them. Once such an account has logged in, conversion is no longer possible.
If you would rather registered users keep their email address as login name, enable "Force email as login name" in the registration app settings.
Custom guest login names
occ guests:addgains--uidto set a free-form login name, instead of always deriving the user ID from the email address (or its hash):Example — create a guest with a chosen login name and verify the user ID:
The guests backend user-id guard is loosened accordingly to accept any non-empty id.
Implementation
ConversionServiceperforms the transactionalusers→guests_usersmove (uid, display name, password hash and email preserved).UsersController::convert()OCS endpoint (admin-only) with the eligibility checks above; routePOST /api/v1/convert.GuestManager::setGuestQuota()extracted so both newly created and converted guests get the configured default quota.occ guests:add --uidfor a free-form login name.--uidoption, the controller endpoint and the conversion service.Testing
Verified on a live instance (screenshots above): created a never-logged-in database account, converted it via the UI, confirmed the backend switched to Guests, the account logs in with the same password, and it appears in the guests list. The action is hidden for accounts that have logged in and for existing guests.
🤖 AI (if applicable)
Assisted-by: ClaudeCode:claude-opus-4-8