diff --git a/src/routes/profile.js b/src/routes/profile.js index cda836e04..3d438d2b7 100644 --- a/src/routes/profile.js +++ b/src/routes/profile.js @@ -21,9 +21,11 @@ const assert = require('assert'), AuditSource = require('../auditsource.js'), BoxError = require('../boxerror.js'), constants = require('../constants.js'), + crypto = require('crypto'), dashboard = require('../dashboard.js'), HttpError = require('connect-lastmile').HttpError, HttpSuccess = require('connect-lastmile').HttpSuccess, + https = require('https'), path = require('path'), paths = require('../paths.js'), safe = require('safetydance'), @@ -150,7 +152,8 @@ async function getAvatar(req, res, next) { if (avatarError) return next(BoxError.toHttpError(avatarError)); if (avatar.equals(constants.AVATAR_GRAVATAR)) { - require('https').get(`https://www.gravatar.com/avatar/${require('crypto').createHash('md5').update(user.email).digest('hex')}.jpg`, function (upstreamRes) { + const gravatarHash = crypto.createHash('md5').update(user.email).digest('hex'); + https.get(`https://www.gravatar.com/avatar/${gravatarHash}.jpg`, function (upstreamRes) { if (upstreamRes.statusCode !== 200) { console.error('Gravatar error:', upstreamRes.statusCode); return res.status(404).end();