Shared workspace-aware auth payload/response builders (ACL-001).
- Source:
Methods
(static) buildJwtPayload(user, workspaceIdHintopt) → {JwtPayload}
Build a JWT payload with a workspace hint.
The JWT carries workspaceId as a routing hint only. Authorization is always
resolved from workspace_members at request time.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
user |
Object | User row from the database. |
|
workspaceIdHint |
string |
<optional> |
Preferred current workspace ID. |
- Source:
Returns:
- Type
- JwtPayload
(static) buildUserResponse(user, workspaceIdHintopt) → {UserResponse}
Build the user response object with workspace context for the frontend.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
user |
Object | User row from the database. |
|
workspaceIdHint |
string |
<optional> |
Preferred current workspace ID. |
- Source:
Returns:
- Type
- UserResponse
(inner) resolveCurrentWorkspace(workspaces, hintopt) → {Object|undefined}
Resolve the current workspace from a user's memberships.
Returns the workspace matching hint, or the first workspace as fallback.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
workspaces |
Array.<Object> | Result of |
|
hint |
string |
<optional> |
Preferred workspace ID. |
- Source:
Returns:
The resolved workspace, or undefined if empty.
- Type
- Object | undefined
Type Definitions
JwtPayload
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
sub |
string | ||
email |
string | ||
name |
string | ||
role |
string | ||
jti |
string | ||
workspaceId |
string |
<optional> |
Present when the user has workspaces. |
- Source:
UserResponse
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
string | ||
name |
string | ||
email |
string | ||
role |
string | ||
avatar |
string | null | ||
workspaceId |
string |
<optional> |
Active workspace ID (present when user has workspaces). |
workspaceName |
string |
<optional> |
Active workspace display name. |
workspaceRole |
string |
<optional> |
User's role in the active workspace. |
workspaces |
Array.<{id: string, name: string, role: string, isOwner: boolean}> |
<optional> |
All workspaces (present when user belongs to 2+). |
- Source: