fix(api,web): separate workspace context from auth session (#551)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #551.
This commit is contained in:
28
apps/api/src/workspaces/workspaces.controller.ts
Normal file
28
apps/api/src/workspaces/workspaces.controller.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Controller, Get, UseGuards } from "@nestjs/common";
|
||||
import { WorkspacesService } from "./workspaces.service";
|
||||
import { AuthGuard } from "../auth/guards/auth.guard";
|
||||
import { CurrentUser } from "../auth/decorators/current-user.decorator";
|
||||
import type { AuthUser } from "@mosaic/shared";
|
||||
import type { WorkspaceResponseDto } from "./dto";
|
||||
|
||||
/**
|
||||
* User-scoped workspace operations.
|
||||
*
|
||||
* Intentionally does NOT use WorkspaceGuard — these routes operate across all
|
||||
* workspaces the user belongs to, not within a single workspace context.
|
||||
*/
|
||||
@Controller("workspaces")
|
||||
@UseGuards(AuthGuard)
|
||||
export class WorkspacesController {
|
||||
constructor(private readonly workspacesService: WorkspacesService) {}
|
||||
|
||||
/**
|
||||
* GET /api/workspaces
|
||||
* Returns workspaces the authenticated user is a member of.
|
||||
* Auto-provisions a default workspace if the user has none.
|
||||
*/
|
||||
@Get()
|
||||
async getUserWorkspaces(@CurrentUser() user: AuthUser): Promise<WorkspaceResponseDto[]> {
|
||||
return this.workspacesService.getUserWorkspaces(user.id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user