@nocobase/plugin-users 1.4.0-alpha.20240903083725 → 1.4.0-alpha.20240906133133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,17 +10,16 @@
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
12
  "antd": "5.12.8",
13
- "@nocobase/client": "1.4.0-alpha.20240903083725",
13
+ "@nocobase/client": "1.4.0-alpha.20240906133133",
14
14
  "@formily/react": "2.3.0",
15
15
  "@formily/core": "2.3.0",
16
- "@nocobase/plugin-acl": "1.4.0-alpha.20240903083725",
17
- "@nocobase/utils": "1.4.0-alpha.20240903083725",
16
+ "@nocobase/plugin-acl": "1.4.0-alpha.20240906133133",
17
+ "@nocobase/utils": "1.4.0-alpha.20240906133133",
18
18
  "react-i18next": "11.18.6",
19
- "@nocobase/database": "1.4.0-alpha.20240903083725",
20
- "@nocobase/server": "1.4.0-alpha.20240903083725",
21
- "@nocobase/cache": "1.4.0-alpha.20240903083725",
22
- "@nocobase/plugin-user-data-sync": "1.4.0-alpha.20240903083725",
19
+ "@nocobase/database": "1.4.0-alpha.20240906133133",
20
+ "@nocobase/server": "1.4.0-alpha.20240906133133",
21
+ "@nocobase/plugin-user-data-sync": "1.4.0-alpha.20240906133133",
23
22
  "lodash": "4.17.21",
24
23
  "@formily/shared": "2.3.0",
25
- "@nocobase/actions": "1.4.0-alpha.20240903083725"
24
+ "@nocobase/actions": "1.4.0-alpha.20240906133133"
26
25
  };
@@ -112,6 +112,10 @@ var users_default = (0, import_database.defineCollection)({
112
112
  "x-component": "Password"
113
113
  }
114
114
  },
115
+ {
116
+ name: "passwordChangeTz",
117
+ type: "bigInt"
118
+ },
115
119
  {
116
120
  type: "string",
117
121
  name: "appLang"
@@ -42,7 +42,6 @@ module.exports = __toCommonJS(server_exports);
42
42
  var import_database = require("@nocobase/database");
43
43
  var import_server = require("@nocobase/server");
44
44
  var import_utils = require("@nocobase/utils");
45
- var import_path = require("path");
46
45
  var actions = __toESM(require("./actions/users"));
47
46
  var import_UserModel = require("./models/UserModel");
48
47
  var import_user_data_sync_resource = require("./user-data-sync-resource");
@@ -178,28 +177,25 @@ class PluginUsersServer extends import_server.Plugin {
178
177
  });
179
178
  }
180
179
  async load() {
181
- await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
182
- this.db.addMigrations({
183
- namespace: "users",
184
- directory: (0, import_path.resolve)(__dirname, "migrations"),
185
- context: {
186
- plugin: this
187
- }
188
- });
189
- this.app.resourcer.use(async (ctx, next) => {
180
+ this.app.resourceManager.use(async (ctx, next) => {
190
181
  await next();
191
182
  const { associatedName, resourceName, actionName, values } = ctx.action.params;
192
- const cache = ctx.app.cache;
193
183
  if (associatedName === "roles" && resourceName === "users" && ["add", "remove", "set"].includes(actionName) && (values == null ? void 0 : values.length)) {
194
- for (const userId of values) {
195
- await cache.del(`roles:${userId}`);
196
- }
184
+ await Promise.all(values.map((userId) => this.app.emitAsync("cache:del:roles", { userId })));
197
185
  }
198
186
  });
199
187
  const userDataSyncPlugin = this.app.pm.get("user-data-sync");
200
188
  if (userDataSyncPlugin && userDataSyncPlugin.enabled) {
201
189
  userDataSyncPlugin.resourceManager.registerResource(new import_user_data_sync_resource.UserDataSyncResource(this.db, this.app.logger));
202
190
  }
191
+ this.app.db.on("users.beforeUpdate", async (model) => {
192
+ if (!model._changed.has("password")) {
193
+ return;
194
+ }
195
+ model.set("passwordChangeTz", Date.now());
196
+ await this.app.emitAsync("cache:del:roles", { userId: model.get("id") });
197
+ await this.app.emitAsync("cache:del:auth", { userId: model.get("id") });
198
+ });
203
199
  }
204
200
  getInstallingData(options = {}) {
205
201
  var _a;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "用户",
5
5
  "description": "Provides basic user model, as well as created by and updated by fields.",
6
6
  "description.zh-CN": "提供了基础的用户模型,以及创建人和最后更新人字段。",
7
- "version": "1.4.0-alpha.20240903083725",
7
+ "version": "1.4.0-alpha.20240906133133",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/users",
@@ -25,7 +25,7 @@
25
25
  "@nocobase/test": "1.x",
26
26
  "@nocobase/utils": "1.x"
27
27
  },
28
- "gitHead": "ed8aee01686cbd1241e0b1a3575b076ec4b9db78",
28
+ "gitHead": "e87488347b8376ba6877306986ecc0c1d2d41542",
29
29
  "keywords": [
30
30
  "Users & permissions"
31
31
  ]