better-auth-studio 1.0.79-beta.21 → 1.0.79-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/png" href="/logo.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Better Auth Studio</title>
8
- <script type="module" crossorigin src="/assets/main-C-eJoLJ_.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-B68uy0QR.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/main-C0mBl_hH.css">
10
10
  </head>
11
11
  <body>
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA2FnE,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAqLhG;AAeD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,gBAAgB,CAAC,EAAE,GAAG,EACtB,oBAAoB,CAAC,EAAE,GAAG,EAC1B,YAAY,CAAC,EAAE,kBAAkB,EACjC,YAAY,CAAC,EAAE,GAAG,GACjB,MAAM,CAg3LR;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;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E,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CAChE,CAAC,CA+FD"}
package/dist/routes.js CHANGED
@@ -932,9 +932,12 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
932
932
  const plugins = betterAuthConfig.plugins || [];
933
933
  const organizationPlugin = plugins.find((plugin) => plugin.id === 'organization');
934
934
  organizationPluginEnabled = !!organizationPlugin;
935
- teamsPluginEnabled = !!organizationPlugin?.options?.teams?.enabled;
936
935
  if (organizationPlugin) {
937
- teamsPluginEnabled = organizationPlugin.options?.teams?.enabled === true;
936
+ teamsPluginEnabled =
937
+ organizationPlugin.options?.teams?.enabled === true ||
938
+ organizationPlugin.teams?.enabled === true ||
939
+ organizationPlugin.config?.teams?.enabled === true ||
940
+ false;
938
941
  }
939
942
  }
940
943
  }
@@ -2372,7 +2375,6 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
2372
2375
  });
2373
2376
  router.get('/api/plugins/teams/status', async (_req, res) => {
2374
2377
  try {
2375
- // Prioritize preloadedAuthOptions for self-hosted mode
2376
2378
  const betterAuthConfig = preloadedAuthOptions || (await getAuthConfigSafe());
2377
2379
  if (!betterAuthConfig) {
2378
2380
  return res.json({
@@ -2384,7 +2386,22 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
2384
2386
  const plugins = betterAuthConfig.plugins || [];
2385
2387
  const organizationPlugin = plugins.find((plugin) => plugin.id === 'organization');
2386
2388
  if (organizationPlugin) {
2387
- const teamsEnabled = organizationPlugin.options?.teams?.enabled === true;
2389
+ let teamsEnabled = false;
2390
+ if (organizationPlugin.options?.teams?.enabled === true) {
2391
+ teamsEnabled = true;
2392
+ }
2393
+ else if (organizationPlugin.teams?.enabled === true) {
2394
+ teamsEnabled = true;
2395
+ }
2396
+ else if (organizationPlugin.config?.teams?.enabled === true) {
2397
+ teamsEnabled = true;
2398
+ }
2399
+ else if (organizationPlugin.options?.teams && typeof organizationPlugin.options.teams === 'object') {
2400
+ teamsEnabled = organizationPlugin.options.teams.enabled === true;
2401
+ }
2402
+ else if (organizationPlugin.teams && typeof organizationPlugin.teams === 'object') {
2403
+ teamsEnabled = organizationPlugin.teams.enabled === true;
2404
+ }
2388
2405
  return res.json({
2389
2406
  enabled: teamsEnabled,
2390
2407
  configPath: isSelfHosted ? null : configPath || null,
@@ -2752,67 +2769,6 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
2752
2769
  res.status(500).json({ error: 'Failed to create invitation' });
2753
2770
  }
2754
2771
  });
2755
- router.get('/api/teams', async (req, res) => {
2756
- try {
2757
- const adapter = await getAuthAdapterWithConfig();
2758
- if (adapter && typeof adapter.findMany === 'function') {
2759
- try {
2760
- const teams = await adapter.findMany({
2761
- model: 'team',
2762
- limit: 10000,
2763
- });
2764
- const transformedTeams = await Promise.all((teams || []).map(async (team) => {
2765
- if (!adapter.findMany) {
2766
- return null;
2767
- }
2768
- // Fetch organization details
2769
- let organization = null;
2770
- try {
2771
- if (team.organizationId) {
2772
- const orgs = await adapter.findMany({
2773
- model: 'organization',
2774
- where: [{ field: 'id', value: team.organizationId }],
2775
- limit: 1,
2776
- });
2777
- organization = orgs && orgs.length > 0 ? orgs[0] : null;
2778
- }
2779
- }
2780
- catch (_error) { }
2781
- // Fetch team members count
2782
- const teamMembers = await adapter.findMany({
2783
- model: 'teamMember',
2784
- where: [{ field: 'teamId', value: team.id }],
2785
- limit: 10000,
2786
- });
2787
- return {
2788
- id: team.id,
2789
- name: team.name,
2790
- organizationId: team.organizationId,
2791
- metadata: team.metadata,
2792
- createdAt: team.createdAt,
2793
- updatedAt: team.updatedAt,
2794
- memberCount: teamMembers ? teamMembers.length : 0,
2795
- organization: organization
2796
- ? {
2797
- id: organization.id,
2798
- name: organization.name,
2799
- slug: organization.slug,
2800
- }
2801
- : null,
2802
- };
2803
- }));
2804
- const validTeams = transformedTeams.filter((team) => team !== null);
2805
- res.json({ success: true, teams: validTeams });
2806
- return;
2807
- }
2808
- catch (_error) { }
2809
- }
2810
- res.json({ success: true, teams: [] });
2811
- }
2812
- catch (_error) {
2813
- res.status(500).json({ error: 'Failed to fetch teams' });
2814
- }
2815
- });
2816
2772
  router.get('/api/organizations/:orgId/teams', async (req, res) => {
2817
2773
  try {
2818
2774
  const { orgId } = req.params;