mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05: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}"
|