From a1fba4ba261ebfc8eedfa468578bb00abbbb11d9 Mon Sep 17 00:00:00 2001 From: chenos Date: Thu, 27 Oct 2022 15:27:08 +0800 Subject: [PATCH] fix(acl): write roles to acl after app load --- packages/plugins/acl/src/server.ts | 6 ++++-- packages/samples/ratelimit/src/server/index.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/plugins/acl/src/server.ts b/packages/plugins/acl/src/server.ts index ce4d515f4..7b19c0e12 100644 --- a/packages/plugins/acl/src/server.ts +++ b/packages/plugins/acl/src/server.ts @@ -268,8 +268,10 @@ export class PluginACL extends Plugin { }); // sync database role data to acl - this.app.on('beforeStart', async () => { - await this.writeRolesToACL(); + this.app.on('afterLoad', async (app, options) => { + if (options.method !== 'install') { + await this.writeRolesToACL(); + } }); this.app.on('beforeInstallPlugin', async (plugin) => { diff --git a/packages/samples/ratelimit/src/server/index.ts b/packages/samples/ratelimit/src/server/index.ts index c9b21dcf3..6b3a083de 100644 --- a/packages/samples/ratelimit/src/server/index.ts +++ b/packages/samples/ratelimit/src/server/index.ts @@ -17,7 +17,7 @@ export class CustomPagePlugin extends Plugin { reset: 'Rate-Limit-Reset', total: 'Rate-Limit-Total', }, - max: 20, + max: 200, disableHeader: false, whitelist: (ctx) => { // some logic that returns a boolean