@plandesk/api 1.0.2 → 1.0.3
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.
- package/dist/routes/auth.d.ts +1 -1
- package/dist/routes/auth.js +10 -3
- package/package.json +1 -1
package/dist/routes/auth.d.ts
CHANGED
package/dist/routes/auth.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
+
import { listProjects } from '@plandesk/db';
|
|
2
3
|
import { createOrgOwnerKey } from '../agent-keys.js';
|
|
3
4
|
import { getAuthContext } from '../auth-context.js';
|
|
4
5
|
import { getActiveTeamForSession, listTeamsForOrg, } from '../identity.js';
|
|
@@ -43,9 +44,15 @@ export function createAuthRouter(deps) {
|
|
|
43
44
|
active ?? (workspaces[0] !== undefined ? workspaces[0] : null);
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
|
-
// Loopback: no session row to carry an active team
|
|
47
|
-
//
|
|
48
|
-
|
|
47
|
+
// Loopback: no session row to carry an active team. Default to the first
|
|
48
|
+
// workspace that actually HAS projects, so an imported/populated board
|
|
49
|
+
// (e.g. after legacy-upgrade --into-workspace) opens on its content
|
|
50
|
+
// instead of an empty default team; fall back to the first workspace.
|
|
51
|
+
const localProjects = await listProjects(deps.db, ctx.orgId);
|
|
52
|
+
const populated = new Set(localProjects.map((project) => project.workspaceId));
|
|
53
|
+
activeWorkspace =
|
|
54
|
+
workspaces.find((workspace) => populated.has(workspace.id)) ??
|
|
55
|
+
(workspaces[0] !== undefined ? workspaces[0] : null);
|
|
49
56
|
}
|
|
50
57
|
}
|
|
51
58
|
return c.json({
|