feat: ownerOf(event) helper and ownerId in task DTO
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
10
server/utils/session.ts
Normal file
10
server/utils/session.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createError, type H3Event } from "h3";
|
||||
|
||||
/** The authenticated caller's Zitadel sub — the ownership key for all row scoping. */
|
||||
export function ownerOf(event: H3Event): string {
|
||||
const sub = (event.context.user as { sub?: unknown } | undefined)?.sub;
|
||||
if (typeof sub !== "string" || !sub) {
|
||||
throw createError({ statusCode: 401, statusMessage: "Unauthorized" });
|
||||
}
|
||||
return sub;
|
||||
}
|
||||
Reference in New Issue
Block a user