[PR #32308] feat(enterprise): auto-join newly registered accounts to the default workspace #33661

Open
opened 2026-02-21 20:53:41 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/32308

State: open
Merged: No


Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Fixes #32307

Summary

This PR adds an enterprise-only, best-effort integration to ensure newly created accounts are members of the enterprise configured default workspace.

  • Calls Enterprise Inner API POST /default-workspace/members with body { "account_id": "<uuid>" }
  • Executes only when ENTERPRISE_ENABLED=true
  • Runs synchronously in the registration/account-creation path, but remains best-effort (errors are swallowed and logged as warnings; signup/login continues)
  • Uses a small request timeout (1s) and treats non-2xx responses as failures
  • Validates account_id as UUID before sending the request
  • Does not change the user’s current workspace (no workspace switch side effects)
  • Integrated into new-account creation paths:
    • OAuth/SSO new user (RegisterService.register)
    • Email-code new user (AccountService.create_account_and_tenant)
  • Adds unit tests covering:
    • Enterprise service request/response handling (including invalid payloads / failures)
    • Registration call sites invoking the integration when enterprise is enabled

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/32308 **State:** open **Merged:** No --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 2. Ensure there is an associated issue and you have been assigned to it > 3. Use the correct syntax to link this PR: `Fixes #<issue number>`. Fixes #32307 ## Summary This PR adds an enterprise-only, best-effort integration to ensure newly created accounts are members of the enterprise configured default workspace. - Calls Enterprise Inner API `POST /default-workspace/members` with body `{ "account_id": "<uuid>" }` - Executes only when `ENTERPRISE_ENABLED=true` - Runs synchronously in the registration/account-creation path, but remains best-effort (errors are swallowed and logged as warnings; signup/login continues) - Uses a small request timeout (`1s`) and treats non-2xx responses as failures - Validates `account_id` as UUID before sending the request - Does not change the user’s current workspace (no workspace switch side effects) - Integrated into new-account creation paths: - OAuth/SSO new user (`RegisterService.register`) - Email-code new user (`AccountService.create_account_and_tenant`) - Adds unit tests covering: - Enterprise service request/response handling (including invalid payloads / failures) - Registration call sites invoking the integration when enterprise is enabled ## Screenshots | Before | After | |--------|-------| | ... | ... | ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `make lint` and `make type-check` (backend) and `cd web && npx lint-staged` (frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:53:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33661