@openinc/parse-server-opendash 3.25.0 → 3.25.2
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.
|
@@ -76,19 +76,31 @@ async function init(name) {
|
|
|
76
76
|
const defaultTenant = await new Parse.Query(types_1.Tenant)
|
|
77
77
|
.ascending("createdAt")
|
|
78
78
|
.first({ useMasterKey: true });
|
|
79
|
-
let user = await new Parse.Query(Parse.User)
|
|
79
|
+
let user = (await new Parse.Query(Parse.User)
|
|
80
|
+
.equalTo("microsoftId", verifiedPayload.oid)
|
|
81
|
+
.first({ useMasterKey: true }));
|
|
82
|
+
// Legacy fallback: some older accounts might have been created using the oid as username.
|
|
83
|
+
let oldUser = (await new Parse.Query(Parse.User)
|
|
80
84
|
.equalTo("username", verifiedPayload.oid)
|
|
81
|
-
.first({ useMasterKey: true });
|
|
82
|
-
if (!user) {
|
|
85
|
+
.first({ useMasterKey: true }));
|
|
86
|
+
if (!user && !oldUser) {
|
|
83
87
|
user = new Parse.User();
|
|
84
|
-
user.set("username",
|
|
88
|
+
user.set("username", account.username);
|
|
85
89
|
user.set("email", account.username);
|
|
86
90
|
user.set("password", (0, crypto_1.randomBytes)(16).toString("hex"));
|
|
91
|
+
user.set("microsoftId", verifiedPayload.oid);
|
|
87
92
|
user.set("name", verifiedPayload.name || verifiedPayload.preferred_username);
|
|
88
93
|
user.set("tenant", defaultTenant);
|
|
89
94
|
user = await user.signUp(null, { useMasterKey: true });
|
|
90
95
|
return user.getSessionToken();
|
|
91
96
|
}
|
|
97
|
+
else if (!user && oldUser) {
|
|
98
|
+
// Migrate legacy account that used the oid as username to a modern record keyed by microsoftId.
|
|
99
|
+
user = oldUser;
|
|
100
|
+
user.set("microsoftId", verifiedPayload.oid);
|
|
101
|
+
user.set("username", account.username);
|
|
102
|
+
user = await user.save(null, { useMasterKey: true });
|
|
103
|
+
}
|
|
92
104
|
const sessionToken = "r:" + (0, crypto_1.randomBytes)(16).toString("hex");
|
|
93
105
|
const session = new Parse.Object("_Session");
|
|
94
106
|
session.set("user", user);
|
|
@@ -34,8 +34,8 @@ async function init() {
|
|
|
34
34
|
template?.relation("sources").remove(source);
|
|
35
35
|
await template?.save(null, { useMasterKey: true });
|
|
36
36
|
// Delete associated calendar event
|
|
37
|
-
if (object.get("meta")?.
|
|
38
|
-
await new CalendarManager_1.CalendarManager().deleteEvent(object.get("meta")?.
|
|
37
|
+
if (object.get("meta")?.microsoftCalendarEventId) {
|
|
38
|
+
await new CalendarManager_1.CalendarManager().deleteEvent(object.get("meta")?.microsoftCalendarEventId);
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -58,10 +58,10 @@ async function updateCalendarEvent(schedule) {
|
|
|
58
58
|
return;
|
|
59
59
|
const calendarManager = new CalendarManager_1.CalendarManager();
|
|
60
60
|
const meta = schedule.get("meta") || {};
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
61
|
+
const microsoftCalendarEventId = meta.microsoftCalendarEventId;
|
|
62
|
+
if (microsoftCalendarEventId) {
|
|
63
63
|
console.log("Updating schedule in calendar...");
|
|
64
|
-
await calendarManager.updateEvent(
|
|
64
|
+
await calendarManager.updateEvent(microsoftCalendarEventId, event);
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
67
|
await addToCalendar(schedule);
|
|
@@ -82,7 +82,7 @@ async function addToCalendar(schedule) {
|
|
|
82
82
|
const existingMeta = schedule.get("meta") || {};
|
|
83
83
|
schedule.set("meta", {
|
|
84
84
|
...existingMeta,
|
|
85
|
-
|
|
85
|
+
microsoftCalendarEventId: createdEvent.id,
|
|
86
86
|
});
|
|
87
87
|
await schedule.save(null, { useMasterKey: true });
|
|
88
88
|
}
|
package/dist/types/_User.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface _UserAttributes {
|
|
|
15
15
|
miaas_cities: any[];
|
|
16
16
|
miaas_userType?: string | undefined;
|
|
17
17
|
miaasUserScope?: string | undefined;
|
|
18
|
+
microsoftId?: string | undefined;
|
|
18
19
|
name?: string | undefined;
|
|
19
20
|
password?: string | undefined;
|
|
20
21
|
settings?: User_Setting | undefined;
|