diff --git a/core/server/models/user.js b/core/server/models/user.js index aeed9437d1..5fa3947272 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -3,9 +3,9 @@ var _ = require('lodash'), errors = require('../errors'), bcrypt = require('bcryptjs'), ghostBookshelf = require('./base'), - http = require('http'), crypto = require('crypto'), validator = require('validator'), + request = require('request'), validation = require('../data/validation'), config = require('../config'), @@ -845,14 +845,16 @@ User = ghostBookshelf.Model.extend({ resolve(userData); } - http.get('http:' + gravatarUrl, function (res) { - if (res.statusCode !== 404) { + request({url: gravatarUrl, timeout: 2000}, function (err, response) { + if (err) { + // just resolve with no image url + resolve(userData); + } + + if (response.statusCode !== 404) { userData.image = gravatarUrl; } - resolve(userData); - }).on('error', function () { - // Error making request just continue. resolve(userData); }); }); diff --git a/package.json b/package.json index 351650bd82..b7873f9d96 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "passport": "0.2.0", "passport-http-bearer": "1.0.1", "passport-oauth2-client-password": "0.1.1", + "request": "2.47.0", "rss": "1.0.0", "semver": "2.2.1", "showdown": "https://github.com/ErisDS/showdown/archive/v0.3.2-ghost.tar.gz", @@ -94,7 +95,6 @@ "matchdep": "~0.3.0", "mocha": "~1.21.4", "nock": "0.47.0", - "request": "~2.42.0", "require-dir": "~0.1.0", "rewire": "~2.1.0", "should": "~4.0.4",