Remove blueimp-md5 dependency
Signed-off-by: Daan Sprenkels <hello@dsprenkels.com>
This commit is contained in:
parent
318a37d41c
commit
f7bc1e99c0
2 changed files with 7 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
// external modules
|
// external modules
|
||||||
const md5 = require('blueimp-md5')
|
const crypto = require('crypto')
|
||||||
const randomcolor = require('randomcolor')
|
const randomcolor = require('randomcolor')
|
||||||
const config = require('./config')
|
const config = require('./config')
|
||||||
|
|
||||||
|
@ -31,15 +31,19 @@ exports.generateAvatarURL = function (name, email = '', big = true) {
|
||||||
email = '' + name + '@example.com'
|
email = '' + name + '@example.com'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hash = crypto.createHash('md5')
|
||||||
|
hash.update(email.toLowerCase())
|
||||||
|
let hexDigest = hash.digest('hex')
|
||||||
|
|
||||||
if (email !== '' && config.allowGravatar) {
|
if (email !== '' && config.allowGravatar) {
|
||||||
photo = 'https://www.gravatar.com/avatar/' + md5(email.toLowerCase())
|
photo = 'https://www.gravatar.com/avatar/' + hexDigest;
|
||||||
if (big) {
|
if (big) {
|
||||||
photo += '?s=400'
|
photo += '?s=400'
|
||||||
} else {
|
} else {
|
||||||
photo += '?s=96'
|
photo += '?s=96'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || md5(email.toLowerCase())) + '/avatar.svg'
|
photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || hexDigest) + '/avatar.svg'
|
||||||
}
|
}
|
||||||
return photo
|
return photo
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
"aws-sdk": "^2.345.0",
|
"aws-sdk": "^2.345.0",
|
||||||
"azure-storage": "^2.7.0",
|
"azure-storage": "^2.7.0",
|
||||||
"base64url": "^3.0.0",
|
"base64url": "^3.0.0",
|
||||||
"blueimp-md5": "^2.6.0",
|
|
||||||
"body-parser": "^1.15.2",
|
"body-parser": "^1.15.2",
|
||||||
"bootstrap": "^3.3.7",
|
"bootstrap": "^3.3.7",
|
||||||
"bootstrap-validator": "^0.11.8",
|
"bootstrap-validator": "^0.11.8",
|
||||||
|
|
Loading…
Reference in a new issue