Spaces:
Running
Running
temp(login): add debug logs
Browse files
src/routes/login/callback/updateUser.ts
CHANGED
@@ -16,6 +16,10 @@ const earlyAccessIds = HF_ORG_EARLY_ACCESS
|
|
16 |
? await fetch(`https://huggingface.co/api/organizations/${HF_ORG_EARLY_ACCESS}/members`)
|
17 |
.then((res) => res.json())
|
18 |
.then((res: Array<{ _id: string }>) => res.map((user: { _id: string }) => user._id))
|
|
|
|
|
|
|
|
|
19 |
.catch((err) => {
|
20 |
logger.error(err, "Failed to fetch early access members");
|
21 |
return null;
|
@@ -26,6 +30,10 @@ const adminIds = HF_ORG_ADMIN
|
|
26 |
? await fetch(`https://huggingface.co/api/organizations/${HF_ORG_ADMIN}/members`)
|
27 |
.then((res) => res.json())
|
28 |
.then((res: Array<{ _id: string }>) => res.map((user) => user._id))
|
|
|
|
|
|
|
|
|
29 |
.catch((err) => {
|
30 |
logger.error(err, "Failed to fetch admin members");
|
31 |
return null;
|
@@ -110,6 +118,15 @@ export async function updateUser(params: {
|
|
110 |
}
|
111 |
}
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
// check if user already exists
|
114 |
const existingUser = await collections.users.findOne({ hfUserId });
|
115 |
let userId = existingUser?._id;
|
|
|
16 |
? await fetch(`https://huggingface.co/api/organizations/${HF_ORG_EARLY_ACCESS}/members`)
|
17 |
.then((res) => res.json())
|
18 |
.then((res: Array<{ _id: string }>) => res.map((user: { _id: string }) => user._id))
|
19 |
+
.then((res) => {
|
20 |
+
logger.debug(`Found ${res.length} early access members`);
|
21 |
+
return res;
|
22 |
+
})
|
23 |
.catch((err) => {
|
24 |
logger.error(err, "Failed to fetch early access members");
|
25 |
return null;
|
|
|
30 |
? await fetch(`https://huggingface.co/api/organizations/${HF_ORG_ADMIN}/members`)
|
31 |
.then((res) => res.json())
|
32 |
.then((res: Array<{ _id: string }>) => res.map((user) => user._id))
|
33 |
+
.then((res) => {
|
34 |
+
logger.debug(`Found ${res.length} admin members`);
|
35 |
+
return res;
|
36 |
+
})
|
37 |
.catch((err) => {
|
38 |
logger.error(err, "Failed to fetch admin members");
|
39 |
return null;
|
|
|
118 |
}
|
119 |
}
|
120 |
|
121 |
+
logger.debug(
|
122 |
+
{
|
123 |
+
isAdmin,
|
124 |
+
isEarlyAccess,
|
125 |
+
hfUserId,
|
126 |
+
},
|
127 |
+
`Updating user ${hfUserId}`
|
128 |
+
);
|
129 |
+
|
130 |
// check if user already exists
|
131 |
const existingUser = await collections.users.findOne({ hfUserId });
|
132 |
let userId = existingUser?._id;
|