@7365admin1/core 3.52.17 → 3.52.19
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/CHANGELOG.md +37 -0
- package/dist/index.js +35 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/harness.mjs +5 -2
- package/test/e2e/onboarding-org-save-diagnosis.e2e.test.mjs +220 -0
- package/test/e2e/subscription-read-scope.e2e.test.mjs +182 -0
- package/test/e2e/user-email-lookup-leak.e2e.test.mjs +68 -1
package/dist/index.mjs
CHANGED
|
@@ -11006,6 +11006,19 @@ function MOrg(value) {
|
|
|
11006
11006
|
|
|
11007
11007
|
// src/repositories/organization.repo.ts
|
|
11008
11008
|
import { ObjectId as ObjectId19 } from "mongodb";
|
|
11009
|
+
var DUPLICATE_FIELD_LABEL = {
|
|
11010
|
+
name: "name",
|
|
11011
|
+
email: "email address"
|
|
11012
|
+
};
|
|
11013
|
+
function duplicatedField(error) {
|
|
11014
|
+
if (error?.code !== 11e3 && !/duplicate/i.test(error?.message ?? "")) {
|
|
11015
|
+
return "";
|
|
11016
|
+
}
|
|
11017
|
+
const fromPattern = Object.keys(error?.keyPattern ?? {})[0];
|
|
11018
|
+
if (fromPattern)
|
|
11019
|
+
return fromPattern;
|
|
11020
|
+
return /index:\s*([A-Za-z0-9_]+?)_\d/.exec(error?.message ?? "")?.[1] ?? "";
|
|
11021
|
+
}
|
|
11009
11022
|
function useOrgRepo() {
|
|
11010
11023
|
const db2 = useAtlas12.getDb();
|
|
11011
11024
|
if (!db2) {
|
|
@@ -11087,8 +11100,21 @@ function useOrgRepo() {
|
|
|
11087
11100
|
await delNamespace();
|
|
11088
11101
|
return id;
|
|
11089
11102
|
} catch (error) {
|
|
11090
|
-
logger9.log({
|
|
11091
|
-
|
|
11103
|
+
logger9.log({
|
|
11104
|
+
level: "error",
|
|
11105
|
+
message: `Organization update failed for ${id}: ${error?.name ?? "Error"}${error?.code !== void 0 ? ` code=${error.code}` : ""}${duplicatedField(error) ? ` key=${duplicatedField(error)}` : ""} fields=[${Object.keys(value ?? {}).join(",")}] ${error?.message ?? ""}`
|
|
11106
|
+
});
|
|
11107
|
+
if (error instanceof AppError3)
|
|
11108
|
+
throw error;
|
|
11109
|
+
const field = duplicatedField(error);
|
|
11110
|
+
if (field) {
|
|
11111
|
+
throw new BadRequestError19(
|
|
11112
|
+
`Another organization already uses this ${DUPLICATE_FIELD_LABEL[field] ?? field}. Please use a different one.`
|
|
11113
|
+
);
|
|
11114
|
+
}
|
|
11115
|
+
throw new InternalServerError9(
|
|
11116
|
+
`Failed to update organization${error?.code !== void 0 ? ` (${error.code})` : ""}.`
|
|
11117
|
+
);
|
|
11092
11118
|
}
|
|
11093
11119
|
}
|
|
11094
11120
|
async function getAll({
|
|
@@ -18091,11 +18117,11 @@ async function requireUserFieldWrite(req, userId, field) {
|
|
|
18091
18117
|
}
|
|
18092
18118
|
|
|
18093
18119
|
// src/utils/user-response.util.ts
|
|
18094
|
-
function
|
|
18120
|
+
function publicIdentity(user) {
|
|
18095
18121
|
if (!user || typeof user !== "object")
|
|
18096
18122
|
return user;
|
|
18097
|
-
const {
|
|
18098
|
-
return
|
|
18123
|
+
const { _id, name, email } = user;
|
|
18124
|
+
return { _id, name, email };
|
|
18099
18125
|
}
|
|
18100
18126
|
|
|
18101
18127
|
// src/controllers/user.controller.ts
|
|
@@ -18187,7 +18213,7 @@ function useUserController() {
|
|
|
18187
18213
|
return;
|
|
18188
18214
|
}
|
|
18189
18215
|
const user = await _getByEmail(email);
|
|
18190
|
-
res.json(
|
|
18216
|
+
res.json(publicIdentity(user));
|
|
18191
18217
|
return;
|
|
18192
18218
|
} catch (error2) {
|
|
18193
18219
|
logger24.log({ level: "error", message: `${error2.message}` });
|
|
@@ -31232,6 +31258,7 @@ function useSubscriptionController() {
|
|
|
31232
31258
|
return;
|
|
31233
31259
|
}
|
|
31234
31260
|
try {
|
|
31261
|
+
await requireOrgAccess(req, _id);
|
|
31235
31262
|
const data = await _getByOrgId(_id);
|
|
31236
31263
|
res.json(data);
|
|
31237
31264
|
return;
|
|
@@ -31258,6 +31285,7 @@ function useSubscriptionController() {
|
|
|
31258
31285
|
const page = parseInt(req.query.page ?? "1");
|
|
31259
31286
|
const status = req.query.status ?? "active";
|
|
31260
31287
|
try {
|
|
31288
|
+
await requirePlatformStaff(req);
|
|
31261
31289
|
const data = await _getSubscriptions({ search, page, status });
|
|
31262
31290
|
res.json(data);
|
|
31263
31291
|
return;
|
|
@@ -86217,7 +86245,7 @@ function useUserControllerV2() {
|
|
|
86217
86245
|
return rejectValidation(error, next);
|
|
86218
86246
|
try {
|
|
86219
86247
|
const user = await _getUserByEmail(value);
|
|
86220
|
-
res.json(
|
|
86248
|
+
res.json(publicIdentity(user));
|
|
86221
86249
|
return;
|
|
86222
86250
|
} catch (err) {
|
|
86223
86251
|
logger202.log({ level: "error", message: `${err.message}` });
|