feat(system-admin): implement revocation of system admin privileges with safeguards
- Added RevokeSystemAdmin functionality to the user service and repository, ensuring atomic checks for self-revoke and last admin scenarios. - Updated the system handler to utilize the new revocation method, improving error handling for various edge cases. - Enhanced the bootstrap process to prevent unintended promotions when system admins already exist. - Refactored related comments and documentation for clarity on the new behavior and safeguards in place.
This commit is contained in:
@@ -510,6 +510,13 @@ func (s *userService) ListSystemAdmins(
|
||||
return s.userRepo.ListSystemAdmins(ctx, offset, limit)
|
||||
}
|
||||
|
||||
// RevokeSystemAdmin removes system-admin privileges through the
|
||||
// repository's transactional guard so concurrent revokes cannot remove
|
||||
// the final administrator.
|
||||
func (s *userService) RevokeSystemAdmin(ctx context.Context, userID, actorID string) (*types.User, error) {
|
||||
return s.userRepo.RevokeSystemAdmin(ctx, userID, actorID)
|
||||
}
|
||||
|
||||
// UpdateUserPreferences applies a partial update over the user's
|
||||
// preferences blob. PATCH semantics: only keys present in `patch`
|
||||
// (non-nil pointer fields) replace the existing value; everything else
|
||||
|
||||
Reference in New Issue
Block a user