From 86309e33bef478056d948a7ea233e3832bfabb22 Mon Sep 17 00:00:00 2001 From: chenos Date: Sat, 7 Oct 2023 21:49:01 +0800 Subject: [PATCH] fix(acl): add rolesUsers through collection --- .../@nocobase/plugin-acl/src/server/server.ts | 37 +++++++++++++++++++ ...> 20221101111111-update-foreign-fields.ts} | 2 +- .../plugin-users/src/server/server.ts | 1 - 3 files changed, 38 insertions(+), 2 deletions(-) rename packages/plugins/@nocobase/plugin-collection-manager/src/server/migrations/{20221101111110-update-foreign-fields.ts => 20221101111111-update-foreign-fields.ts} (94%) diff --git a/packages/plugins/@nocobase/plugin-acl/src/server/server.ts b/packages/plugins/@nocobase/plugin-acl/src/server/server.ts index e9e522cb2f..9d1ad2fba3 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-acl/src/server/server.ts @@ -381,6 +381,43 @@ export class PluginACL extends Plugin { default: true, }, }); + const data = { + name: 'rolesUsers', + title: 'rolesUsers', + hidden: true, + fields: [ + { + name: 'roleName', + type: 'string', + interface: 'input', + isForeignKey: true, + uiSchema: { + type: 'string', + title: 'roleName', + 'x-component': 'Input', + 'x-read-pretty': true, + }, + }, + { + name: 'userId', + type: 'bigInt', + interface: 'integer', + isForeignKey: true, + uiSchema: { + type: 'number', + title: 'userId', + 'x-component': 'InputNumber', + 'x-read-pretty': true, + }, + }, + ], + timestamps: true, + autoGenId: false, + autoCreate: true, + isThrough: true, + sortable: false, + }; + await this.db.getRepository('collections').create({ values: data }); }); this.app.on('beforeInstallPlugin', async (plugin) => { diff --git a/packages/plugins/@nocobase/plugin-collection-manager/src/server/migrations/20221101111110-update-foreign-fields.ts b/packages/plugins/@nocobase/plugin-collection-manager/src/server/migrations/20221101111111-update-foreign-fields.ts similarity index 94% rename from packages/plugins/@nocobase/plugin-collection-manager/src/server/migrations/20221101111110-update-foreign-fields.ts rename to packages/plugins/@nocobase/plugin-collection-manager/src/server/migrations/20221101111111-update-foreign-fields.ts index 0bc430b7b2..a07f85f9d4 100644 --- a/packages/plugins/@nocobase/plugin-collection-manager/src/server/migrations/20221101111110-update-foreign-fields.ts +++ b/packages/plugins/@nocobase/plugin-collection-manager/src/server/migrations/20221101111111-update-foreign-fields.ts @@ -3,7 +3,7 @@ import { afterCreateForForeignKeyField } from '../hooks/afterCreateForForeignKey export default class DropForeignKeysMigration extends Migration { async up() { - const result = await this.app.version.satisfies('<0.8.0'); + const result = await this.app.version.satisfies('<0.14.0-alpha.8'); if (!result) { return; diff --git a/packages/plugins/@nocobase/plugin-users/src/server/server.ts b/packages/plugins/@nocobase/plugin-users/src/server/server.ts index b1f5f811f7..9c009462fb 100644 --- a/packages/plugins/@nocobase/plugin-users/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-users/src/server/server.ts @@ -9,7 +9,6 @@ import * as actions from './actions/users'; import initAuthenticators from './authenticators'; import { JwtOptions, JwtService } from './jwt-service'; import { enUS, zhCN } from './locale'; -import { parseToken } from './middlewares'; export interface UserPluginConfig { name?: string;