@7365admin1/core 3.60.1-staging.272 → 3.60.1-staging.274
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/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/guard-invite-wiring.test.mjs +48 -0
package/dist/index.js
CHANGED
|
@@ -29743,6 +29743,7 @@ function useOrgController() {
|
|
|
29743
29743
|
const { inviteId, ...body } = req.body ?? {};
|
|
29744
29744
|
let invitedFrom = null;
|
|
29745
29745
|
let invitedRole = null;
|
|
29746
|
+
let inviteAlreadyComplete = false;
|
|
29746
29747
|
let self = null;
|
|
29747
29748
|
if (inviteId) {
|
|
29748
29749
|
const [invite, caller] = await Promise.all([
|
|
@@ -29754,6 +29755,7 @@ function useOrgController() {
|
|
|
29754
29755
|
if (samePerson) {
|
|
29755
29756
|
invitedFrom = String(invite._id);
|
|
29756
29757
|
invitedRole = invite.metadata?.role ? String(invite.metadata.role) : null;
|
|
29758
|
+
inviteAlreadyComplete = invite.status === "complete" /* COMPLETE */;
|
|
29757
29759
|
} else {
|
|
29758
29760
|
import_node_server_utils67.logger.log({
|
|
29759
29761
|
level: "warn",
|
|
@@ -29770,6 +29772,19 @@ function useOrgController() {
|
|
|
29770
29772
|
}
|
|
29771
29773
|
}
|
|
29772
29774
|
const _id = await _add({ ...body, createdBy, invitedFrom, invitedRole });
|
|
29775
|
+
if (invitedFrom && !inviteAlreadyComplete) {
|
|
29776
|
+
try {
|
|
29777
|
+
await useVerificationRepoV2().updateStatusById(
|
|
29778
|
+
invitedFrom,
|
|
29779
|
+
"complete" /* COMPLETE */
|
|
29780
|
+
);
|
|
29781
|
+
} catch (error2) {
|
|
29782
|
+
import_node_server_utils67.logger.log({
|
|
29783
|
+
level: "error",
|
|
29784
|
+
message: `[organizations/onboarding] could not close invitation ${invitedFrom} for organization ${_id}: ${error2?.message}`
|
|
29785
|
+
});
|
|
29786
|
+
}
|
|
29787
|
+
}
|
|
29773
29788
|
const seededRoles = await seedDefaultRoles(_id, body.nature);
|
|
29774
29789
|
try {
|
|
29775
29790
|
const ownerRole = invitedRole || seededRoles.find((role) => role.type === "organization")?.id || "";
|
|
@@ -53410,7 +53425,11 @@ function useVisitorTransactionService() {
|
|
|
53410
53425
|
org: estate.org,
|
|
53411
53426
|
site: estate.site,
|
|
53412
53427
|
status: value?.type === "contractor" ? isAutoApprovedInvitation ? "approved" /* APPROVED */ : "pending" /* PENDING */ : "approved" /* APPROVED */,
|
|
53413
|
-
inviterId: userId
|
|
53428
|
+
inviterId: userId,
|
|
53429
|
+
// Spread conditionally, exactly as the member fan-out does, so a caller
|
|
53430
|
+
// that names no origin leaves the key absent rather than writing null.
|
|
53431
|
+
// `memberPayload` is derived from this object, so members inherit it.
|
|
53432
|
+
...estate.source ? { source: estate.source } : {}
|
|
53414
53433
|
};
|
|
53415
53434
|
const leadId = new import_mongodb88.ObjectId();
|
|
53416
53435
|
const insertedIds = [];
|
|
@@ -53465,6 +53484,10 @@ function useVisitorTransactionService() {
|
|
|
53465
53484
|
level: null,
|
|
53466
53485
|
unit: null,
|
|
53467
53486
|
unitName: null,
|
|
53487
|
+
// Stamps the record as raised at a gate rather than from a home, so a
|
|
53488
|
+
// reader can tell a guard's invitation from a resident's. "guard" matches
|
|
53489
|
+
// the route (`/guard-invite`) and this function, not the app's brand name.
|
|
53490
|
+
source: "guard",
|
|
53468
53491
|
// `orgId` is the real field on `sites`; `org` is read as a fallback
|
|
53469
53492
|
// exactly as `resolveSiteAccess` and `entitledSites` already do.
|
|
53470
53493
|
org: (site?.orgId ?? site?.org)?.toString(),
|
|
@@ -58446,7 +58469,7 @@ function useVisitorTransactionController() {
|
|
|
58446
58469
|
next(new import_node_server_utils140.InternalServerError("Failed to create visitor invitation."));
|
|
58447
58470
|
return;
|
|
58448
58471
|
}
|
|
58449
|
-
res.status(200).json({ insertedId: leadId });
|
|
58472
|
+
res.status(200).json({ insertedId: leadId, inviterId: inviterUserId });
|
|
58450
58473
|
return;
|
|
58451
58474
|
} catch (error2) {
|
|
58452
58475
|
import_node_server_utils140.logger.log({ level: "error", message: error2.message });
|