mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
Force a default gravatar if no email provided
Gravatar provides the forceDefault option, let's use it.
This commit is contained in:
11
src/user.js
11
src/user.js
@@ -224,13 +224,14 @@ var utils = require('./../public/src/utils.js'),
|
||||
};
|
||||
|
||||
User.createGravatarURLFromEmail = function(email) {
|
||||
var forceDefault = ''
|
||||
if (!email) {
|
||||
email = utils.generateUUID();
|
||||
email = '0000',
|
||||
forceDefault = '&forceDefault=y';
|
||||
}
|
||||
var md5sum = crypto.createHash('md5');
|
||||
md5sum.update(email.toLowerCase().trim());
|
||||
var gravatarURL = 'http://www.gravatar.com/avatar/' + md5sum.digest('hex') + '?default=identicon&s=128';
|
||||
return gravatarURL;
|
||||
var emailHash = crypto.createHash('md5').update(email.toLowerCase().trim()).digest('hex');
|
||||
// @todo: https asset support?
|
||||
return 'http://www.gravatar.com/avatar/' + emailHash + '?default=identicon&s=128' + forceDefault;
|
||||
}
|
||||
|
||||
User.hashPassword = function(password, callback) {
|
||||
|
||||
Reference in New Issue
Block a user