feat(auth): support tenantless provisioning and gated self-service workspace creation

Allow deployments to register users without auto-creating a personal tenant, expose creation policy via /auth/me, and guide tenantless accounts through a workspace onboarding flow.
This commit is contained in:
wizardchen
2026-07-13 18:04:14 +08:00
committed by lyingbug
parent 50b8c0a72e
commit ecf2c1fb9b
36 changed files with 1543 additions and 89 deletions
+13
View File
@@ -490,6 +490,19 @@ func (h *TenantInvitationHandler) AcceptMyInvitation(c *gin.Context) {
return
}
// A tenantless account adopts the first accepted invitation as its
// default tenant. Membership remains the authorization source; TenantID
// only supplies the login/navigation default.
if user, userErr := h.userService.GetUserByID(ctx, caller); userErr == nil && user != nil && user.TenantID == 0 {
user.TenantID = member.TenantID
if updateErr := h.userService.UpdateUser(ctx, user); updateErr != nil {
logger.Errorf(ctx, "AcceptMyInvitation failed to set default tenant: user=%s tenant=%d err=%v",
caller, member.TenantID, updateErr)
c.Error(apperrors.NewInternalServerError("invitation accepted but default tenant update failed").WithDetails(updateErr.Error()))
return
}
}
c.JSON(http.StatusOK, gin.H{
"success": true,
"data": gin.H{