Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

fix(optimization): limit fields retrieval for user #188

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/server/getUserByLoginToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export async function getUserByLoginToken(loginToken) {
// the hashed token is the key to find the possible current user in the db
const hashedToken = Accounts._hashLoginToken(loginToken);

// get the possible user from the database
const user = await Meteor.users.rawCollection().findOne({ [USER_TOKEN_PATH]: hashedToken });
// get the possible user from the database with minimal fields
const fields = { _id: 1, 'services.resume': 1 };
const user = await Meteor.users.rawCollection()
.findOne({ [USER_TOKEN_PATH]: hashedToken }, { fields });

if (!user) { throw NO_VALID_USER_ERROR; }

Expand Down