mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
18 lines
487 B
CoffeeScript
18 lines
487 B
CoffeeScript
crypto = require "crypto"
|
|
|
|
module.exports = UserFormatter =
|
|
formatUserForClientSide: (user) ->
|
|
if user._id?
|
|
user.id = user._id.toString()
|
|
delete user._id
|
|
return {
|
|
id: user.id
|
|
first_name: user.first_name
|
|
last_name: user.last_name
|
|
email: user.email
|
|
gravatar_url: @_getGravatarUrlForEmail(user.email)
|
|
}
|
|
|
|
_getGravatarUrlForEmail: (email) ->
|
|
hash = crypto.createHash("md5").update(email.toLowerCase()).digest("hex")
|
|
return "//www.gravatar.com/avatar/#{hash}"
|