Skip to content

Commit 072f8a2

Browse files
committed
fix(dev): DevPlugin derives org roles from its stack too (#3723)
The fourth host that boots AuthPlugin from a loaded stack, and the last one still walking past `additionalOrgRoles`. Unlike the pre-fix `serve` path this was not a mismatch — passing nothing left better-auth and the selects agreeing on the built-ins — but DevPlugin documents itself as equivalent to assembling the full stack by hand, and that equivalence quietly excluded every app-declared organization role. Now uses the same `collectStackOrgRoles(this.options.stack)` as `serve` and the verify harness. Guarded on the export being present: plugin-auth is a dynamic optional import here, so an older copy on disk yields none rather than throwing.
1 parent cb8434e commit 072f8a2

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

packages/plugins/plugin-dev/src/dev-plugin.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,21 @@ export class DevPlugin implements Plugin {
522522
let authMounted = false;
523523
if (enabled('auth')) {
524524
try {
525-
const { AuthPlugin } = await import('@objectstack/plugin-auth') as any;
525+
const { AuthPlugin, collectStackOrgRoles } = await import('@objectstack/plugin-auth') as any;
526+
// [#3723] The same stack walk `objectstack serve` and the verify
527+
// harness use. DevPlugin advertises itself as equivalent to the full
528+
// stack, so a stack whose declared positions / permission sets are
529+
// invitable under `serve` must be invitable here too — otherwise
530+
// "equivalent" quietly excludes app-declared organization roles.
531+
// Guarded: an older plugin-auth on disk simply yields none.
532+
const additionalOrgRoles: string[] =
533+
typeof collectStackOrgRoles === 'function'
534+
? collectStackOrgRoles(this.options.stack, ctx.logger)
535+
: [];
526536
const authPlugin = new AuthPlugin({
527537
secret: this.options.authSecret,
528538
baseUrl: this.options.authBaseUrl,
539+
...(additionalOrgRoles.length > 0 ? { additionalOrgRoles } : {}),
529540
});
530541
this.childPlugins.push(authPlugin);
531542
authMounted = true;

0 commit comments

Comments
 (0)