@nocobase/plugin-users 1.4.0-alpha.20240828033319 → 1.4.0-alpha.20240902071446
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.
package/dist/externalVersion.js
CHANGED
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"antd": "5.12.8",
|
|
13
|
-
"@nocobase/client": "1.4.0-alpha.
|
|
13
|
+
"@nocobase/client": "1.4.0-alpha.20240902071446",
|
|
14
14
|
"@formily/react": "2.3.0",
|
|
15
15
|
"@formily/core": "2.3.0",
|
|
16
|
-
"@nocobase/plugin-acl": "1.4.0-alpha.
|
|
17
|
-
"@nocobase/utils": "1.4.0-alpha.
|
|
16
|
+
"@nocobase/plugin-acl": "1.4.0-alpha.20240902071446",
|
|
17
|
+
"@nocobase/utils": "1.4.0-alpha.20240902071446",
|
|
18
18
|
"react-i18next": "11.18.6",
|
|
19
|
-
"@nocobase/database": "1.4.0-alpha.
|
|
20
|
-
"@nocobase/server": "1.4.0-alpha.
|
|
21
|
-
"@nocobase/cache": "1.4.0-alpha.
|
|
22
|
-
"@nocobase/plugin-user-data-sync": "1.4.0-alpha.
|
|
19
|
+
"@nocobase/database": "1.4.0-alpha.20240902071446",
|
|
20
|
+
"@nocobase/server": "1.4.0-alpha.20240902071446",
|
|
21
|
+
"@nocobase/cache": "1.4.0-alpha.20240902071446",
|
|
22
|
+
"@nocobase/plugin-user-data-sync": "1.4.0-alpha.20240902071446",
|
|
23
|
+
"lodash": "4.17.21",
|
|
23
24
|
"@formily/shared": "2.3.0",
|
|
24
|
-
"@nocobase/actions": "1.4.0-alpha.
|
|
25
|
-
"lodash": "4.17.21"
|
|
25
|
+
"@nocobase/actions": "1.4.0-alpha.20240902071446"
|
|
26
26
|
};
|
package/dist/server/server.js
CHANGED
|
@@ -197,7 +197,7 @@ class PluginUsersServer extends import_server.Plugin {
|
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
199
|
const userDataSyncPlugin = this.app.pm.get("user-data-sync");
|
|
200
|
-
if (userDataSyncPlugin) {
|
|
200
|
+
if (userDataSyncPlugin && userDataSyncPlugin.enabled) {
|
|
201
201
|
userDataSyncPlugin.resourceManager.registerResource(new import_user_data_sync_resource.UserDataSyncResource(this.db, this.app.logger));
|
|
202
202
|
}
|
|
203
203
|
}
|
|
@@ -7,11 +7,13 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Model } from '@nocobase/database';
|
|
10
|
+
import lodash from 'lodash';
|
|
10
11
|
import { FormatUser, OriginRecord, PrimaryKey, RecordResourceChanged, SyncAccept, UserDataResource } from '@nocobase/plugin-user-data-sync';
|
|
11
12
|
export declare class UserDataSyncResource extends UserDataResource {
|
|
12
13
|
name: string;
|
|
13
14
|
accepts: SyncAccept[];
|
|
14
15
|
get userRepo(): import("@nocobase/database").Repository<any, any>;
|
|
16
|
+
getFlteredSourceUser(sourceUser: FormatUser): lodash.Omit<FormatUser, string>;
|
|
15
17
|
updateUser(user: Model, sourceUser: FormatUser): Promise<void>;
|
|
16
18
|
update(record: OriginRecord, resourcePks: PrimaryKey[], matchKey: string): Promise<RecordResourceChanged[]>;
|
|
17
19
|
create(record: OriginRecord, matchKey: string): Promise<RecordResourceChanged[]>;
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __export = (target, all) => {
|
|
15
17
|
for (var name in all)
|
|
@@ -23,12 +25,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
25
|
}
|
|
24
26
|
return to;
|
|
25
27
|
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
26
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
37
|
var user_data_sync_resource_exports = {};
|
|
28
38
|
__export(user_data_sync_resource_exports, {
|
|
29
39
|
UserDataSyncResource: () => UserDataSyncResource
|
|
30
40
|
});
|
|
31
41
|
module.exports = __toCommonJS(user_data_sync_resource_exports);
|
|
42
|
+
var import_lodash = __toESM(require("lodash"));
|
|
32
43
|
var import_plugin_user_data_sync = require("@nocobase/plugin-user-data-sync");
|
|
33
44
|
class UserDataSyncResource extends import_plugin_user_data_sync.UserDataResource {
|
|
34
45
|
name = "users";
|
|
@@ -36,6 +47,24 @@ class UserDataSyncResource extends import_plugin_user_data_sync.UserDataResource
|
|
|
36
47
|
get userRepo() {
|
|
37
48
|
return this.db.getRepository("users");
|
|
38
49
|
}
|
|
50
|
+
getFlteredSourceUser(sourceUser) {
|
|
51
|
+
const deleteProps = [
|
|
52
|
+
"id",
|
|
53
|
+
"uid",
|
|
54
|
+
"createdAt",
|
|
55
|
+
"updatedAt",
|
|
56
|
+
"appLang",
|
|
57
|
+
"resetToken",
|
|
58
|
+
"systemSettings",
|
|
59
|
+
"password",
|
|
60
|
+
"sort",
|
|
61
|
+
"createdById",
|
|
62
|
+
"updatedById",
|
|
63
|
+
"isDeleted",
|
|
64
|
+
"departments"
|
|
65
|
+
];
|
|
66
|
+
return import_lodash.default.omit(sourceUser, deleteProps);
|
|
67
|
+
}
|
|
39
68
|
async updateUser(user, sourceUser) {
|
|
40
69
|
if (sourceUser.isDeleted) {
|
|
41
70
|
const roles = await user.getRoles();
|
|
@@ -48,22 +77,13 @@ class UserDataSyncResource extends import_plugin_user_data_sync.UserDataResource
|
|
|
48
77
|
return;
|
|
49
78
|
}
|
|
50
79
|
let dataChanged = false;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
if (sourceUser.email !== void 0 && user.email !== sourceUser.email) {
|
|
60
|
-
user.email = sourceUser.email;
|
|
61
|
-
dataChanged = true;
|
|
62
|
-
}
|
|
63
|
-
if (sourceUser.nickname !== void 0 && user.nickname !== sourceUser.nickname) {
|
|
64
|
-
user.nickname = sourceUser.nickname;
|
|
65
|
-
dataChanged = true;
|
|
66
|
-
}
|
|
80
|
+
const filteredSourceUser = this.getFlteredSourceUser(sourceUser);
|
|
81
|
+
import_lodash.default.forOwn(filteredSourceUser, (value, key) => {
|
|
82
|
+
if (user[key] !== value) {
|
|
83
|
+
user[key] = value;
|
|
84
|
+
dataChanged = true;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
67
87
|
if (dataChanged) {
|
|
68
88
|
await user.save();
|
|
69
89
|
}
|
|
@@ -94,13 +114,9 @@ class UserDataSyncResource extends import_plugin_user_data_sync.UserDataResource
|
|
|
94
114
|
if (user) {
|
|
95
115
|
await this.updateUser(user, sourceUser);
|
|
96
116
|
} else {
|
|
117
|
+
const filteredSourceUser = this.getFlteredSourceUser(sourceUser);
|
|
97
118
|
user = await this.userRepo.create({
|
|
98
|
-
values:
|
|
99
|
-
nickname: sourceUser.nickname,
|
|
100
|
-
phone: sourceUser.phone,
|
|
101
|
-
email: sourceUser.email,
|
|
102
|
-
username: sourceUser.username
|
|
103
|
-
}
|
|
119
|
+
values: filteredSourceUser
|
|
104
120
|
});
|
|
105
121
|
}
|
|
106
122
|
return [{ resourcesPk: user.id, isDeleted: false }];
|
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.
|
|
7
|
+
"version": "1.4.0-alpha.20240902071446",
|
|
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": "
|
|
28
|
+
"gitHead": "4d4e251f16b9909359938e66bc5d2cb84a3e9aa9",
|
|
29
29
|
"keywords": [
|
|
30
30
|
"Users & permissions"
|
|
31
31
|
]
|