diff --git a/packages/app/src/api/index.ts b/packages/app/src/api/index.ts index be05ef986..44923e15f 100644 --- a/packages/app/src/api/index.ts +++ b/packages/app/src/api/index.ts @@ -77,6 +77,9 @@ api.resourcer.use(async (ctx: actions.Context, next) => { }); await api.database.getModel('collections').load({skipExisting: true}); + await api.database.getModel('collections').load({where: { + name: 'users', + }}); api.listen(process.env.HTTP_PORT, () => { console.log(`http://localhost:${process.env.HTTP_PORT}/`); }); diff --git a/packages/app/src/api/migrations/add-lock-to-actions-scopes.ts b/packages/app/src/api/migrations/add-lock-to-actions-scopes.ts new file mode 100644 index 000000000..0e8ffc48e --- /dev/null +++ b/packages/app/src/api/migrations/add-lock-to-actions-scopes.ts @@ -0,0 +1,19 @@ +import api from '../app'; +import Database from '@nocobase/database'; + +(async () => { + await api.loadPlugins(); + const database: Database = api.database; + await api.database.sync({ + tables: ['actions_scopes'], + }); + + const [Collection, User, Role] = database.getModels(['collections', 'users', 'roles']); + + const tables = database.getTables(['actions_scopes']); + + for (let table of tables) { + console.log(table.getName()); + await Collection.import(table.getOptions(), { update: true, migrate: false }); + } +})(); diff --git a/packages/plugin-pages/src/actions/getView.ts b/packages/plugin-pages/src/actions/getView.ts index 6232326b0..58acca9a3 100644 --- a/packages/plugin-pages/src/actions/getView.ts +++ b/packages/plugin-pages/src/actions/getView.ts @@ -211,7 +211,7 @@ export default async (ctx, next) => { let throughName; const { resourceKey: resourceKey2, associatedName, resourceFieldName, associatedKey } = values; // TODO: 暂时不处理 developerMode 和 internal 的情况 - const permissions = (ctx.ac.isRoot() || collection.developerMode || collection.internal) + const permissions = (await ctx.ac.isRoot() || collection.developerMode || collection.internal) ? await ctx.ac.getRootPermissions() : await ctx.ac.can(resourceName).permissions(); ctx.listFields = []; @@ -235,6 +235,7 @@ export default async (ctx, next) => { } } // console.log({ + // a: (await ctx.ac.isRoot() || collection.developerMode || collection.internal), // listFields: ctx.listFields, // createFields: ctx.createFields, // updateFields: ctx.updateFields,