@openinc/parse-server-opendash 3.29.9 → 3.29.11

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.
@@ -39,8 +39,9 @@ function getKey(header, callback) {
39
39
  * @param accessToken The access token to authenticate the request.
40
40
  * @returns The email address of the user.
41
41
  */
42
- async function getUserMail(accessToken) {
43
- const response = await fetch("https://graph.microsoft.com/v1.0/me", {
42
+ async function getUserMail(accessToken, userid) {
43
+ console.log("Fetching Microsoft user info for user ID:", userid, "with token:", accessToken);
44
+ const response = await fetch(`https://graph.microsoft.com/v1.0/me`, {
44
45
  method: "GET",
45
46
  headers: {
46
47
  Authorization: `Bearer ${accessToken}`,
@@ -67,6 +68,7 @@ async function init(name) {
67
68
  Parse.Cloud.define(name, async (request) => {
68
69
  const token = request.params.token;
69
70
  const account = request.params.account;
71
+ console.log(JSON.stringify(request.params));
70
72
  if (!token) {
71
73
  throw new Parse.Error(Parse.Error.INVALID_JSON, "Token missing");
72
74
  }
@@ -102,7 +104,11 @@ async function init(name) {
102
104
  resolve(decoded);
103
105
  });
104
106
  });
105
- const usermail = await getUserMail(request.params.accessToken);
107
+ console.log("Payload: ", JSON.stringify(verifiedPayload));
108
+ let usermail = null;
109
+ if (verifiedPayload.oid) {
110
+ usermail = await getUserMail(token, verifiedPayload.oid);
111
+ }
106
112
  const defaultTenant = await new Parse.Query(types_1.Tenant)
107
113
  .ascending("createdAt")
108
114
  .first({ useMasterKey: true });
@@ -113,7 +119,6 @@ async function init(name) {
113
119
  let oldUser = (await new Parse.Query(Parse.User)
114
120
  .equalTo("username", verifiedPayload.oid)
115
121
  .first({ useMasterKey: true }));
116
- console.log("Payload: ", JSON.stringify(verifiedPayload), "account:", JSON.stringify(account));
117
122
  if (!user && !oldUser) {
118
123
  user = new Parse.User();
119
124
  user.set("username", account.username);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "3.29.9",
3
+ "version": "3.29.11",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@10.20.0",
6
6
  "keywords": [