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
4 changes: 3 additions & 1 deletion packages/plugins/plugin-hono-server/src/hono-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,9 @@ export class HonoServerPlugin implements Plugin {
'sys_user',
{ where: { id: userId }, limit: 1, ...sysCtx } as any,
).catch(() => []);
if ((uRows?.[0] as any)?.ai_access === true) permissions.push('ai_seat');
// Turso returns sqlite booleans as 1/0; memory driver as boolean.
const aiAccess = (uRows?.[0] as any)?.ai_access;
if (aiAccess === true || aiAccess === 1 || aiAccess === '1') permissions.push('ai_seat');
} catch {
/* no ai_access column / query failed → no seat (safe) */
}
Expand Down
6 changes: 5 additions & 1 deletion packages/runtime/src/security/resolve-execution-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,11 @@ export async function resolveExecutionContext(opts: ResolveOptions): Promise<Exe
// Guarded (tryFind swallows errors) → can only ever ADD access, never break auth.
if (userId && !ctx.permissions!.includes('ai_seat')) {
const seatRows = await tryFind(ql, 'sys_user', { id: userId }, 1);
if ((seatRows?.[0] as { ai_access?: unknown } | undefined)?.ai_access === true) {
// Turso/libSQL returns sqlite booleans as integer 1/0; the memory driver
// returns a JS boolean. Accept both (+ the stringified form) so the seat
// resolves regardless of the env's data driver.
const aiAccess = (seatRows?.[0] as { ai_access?: unknown } | undefined)?.ai_access;
if (aiAccess === true || aiAccess === 1 || aiAccess === '1') {
ctx.permissions!.push('ai_seat');
}
}
Expand Down