Skip to content

Commit

Permalink
curator/api: use user.id in logging
Browse files Browse the repository at this point in the history
The user object passed from the request (req) does not have
the _id field, but has id as string; use that instead of _id
for logging and updating the user document.
  • Loading branch information
abhidg committed Oct 21, 2022
1 parent 399815b commit d95a90b
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions verification/curator-service/api/src/controllers/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class CasesController {
try {
const user = req.user as IUser;
const result = await users().findOneAndUpdate(
{ _id: new ObjectId(user._id) },
{ _id: new ObjectId(user.id) },
{
$push: {
downloads: {
Expand All @@ -93,10 +93,7 @@ export default class CasesController {
},
},
);
this.logOutcomeOfAppendingDownloadToUser(
user._id.toHexString(),
result,
);
this.logOutcomeOfAppendingDownloadToUser(user.id, result);

axios({
method: 'post',
Expand Down Expand Up @@ -152,7 +149,7 @@ export default class CasesController {
);
const result = await users().findOneAndUpdate(
{
_id: new ObjectId(user._id),
_id: new ObjectId(user.id),
},
{
$push: {
Expand All @@ -165,10 +162,7 @@ export default class CasesController {
},
);

this.logOutcomeOfAppendingDownloadToUser(
user._id.toHexString(),
result,
);
this.logOutcomeOfAppendingDownloadToUser(user.id, result);

axios({
method: 'post',
Expand Down Expand Up @@ -227,7 +221,7 @@ export default class CasesController {
});

const result = await users().findOneAndUpdate(
{ _id: new ObjectId(user._id) },
{ _id: new ObjectId(user.id) },
{
$push: {
downloads: {
Expand All @@ -236,10 +230,7 @@ export default class CasesController {
},
},
);
this.logOutcomeOfAppendingDownloadToUser(
user._id.toHexString(),
result,
);
this.logOutcomeOfAppendingDownloadToUser(user.id, result);

res.status(200).send({ signedUrl });
} catch (err) {
Expand Down Expand Up @@ -278,7 +269,7 @@ export default class CasesController {
});

const result = await users().findOneAndUpdate(
{ _id: new ObjectId(user._id) },
{ _id: new ObjectId(user.id) },
{
$push: {
downloads: {
Expand All @@ -289,10 +280,7 @@ export default class CasesController {
},
},
);
this.logOutcomeOfAppendingDownloadToUser(
user._id.toHexString(),
result,
);
this.logOutcomeOfAppendingDownloadToUser(user.id, result);

res.status(200).send({ signedUrl });
} catch (err) {
Expand Down

0 comments on commit d95a90b

Please sign in to comment.