Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/me-localization-endpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@objectstack/plugin-hono-server": minor
---

Expose resolved regional defaults to every authenticated user.

Adds `GET /api/v1/auth/me/localization` returning the request tenant's resolved
`{ currency, locale, timezone }` from the ExecutionContext (ADR-0053). The
`localization` SETTINGS are gated to `setup.access`, but the resolved defaults
are needed by every renderer to format currency/dates/numbers — so they are
surfaced here without that gate. Enables a client to format a currency field
in the tenant's default currency when the field omits its own.
19 changes: 19 additions & 0 deletions packages/plugins/plugin-hono-server/src/hono-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,25 @@ export class HonoServerPlugin implements Plugin {
}
});

// GET /me/localization — the resolved regional defaults (currency /
// locale / timezone) for the current request's tenant, exposed to EVERY
// authenticated user. The `localization` SETTINGS are gated to
// `setup.access`, but the resolved defaults are needed by every renderer
// to format currency/dates/numbers — so they ride on the request
// ExecutionContext (ADR-0053) and are surfaced here without that gate.
rawApp.get(`${prefix}/auth/me/localization`, async (c: any) => {
const execCtx = await resolveCtx(c);
if (!execCtx?.userId) {
return c.json({ authenticated: false });
}
return c.json({
authenticated: true,
currency: execCtx.currency ?? null,
locale: execCtx.locale ?? null,
timezone: execCtx.timezone ?? null,
});
});

// GET /me/apps — list apps the current user is allowed to enter.
// Filters `metadata.list('app')` by:
// 1. AppSchema.requiredPermissions ⊆ ctx.systemPermissions
Expand Down
Loading