How to use gravatar - 10 common examples

To help you get started, we’ve selected a few gravatar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jeffersonRibeiro / react-nodejs-mongodb-crud / server / components / users / usersController.js View on Github external
.then(user => {
      if(user) {
        return res.json({
          status: 'EMAIL_ALREADY_EXISTS',
          message: 'Email já existe',
        });
      }
      
      const profile = gravatar.url(req.body.email, {
        s: 200, // size
        r: 'pg', // ratings
        d: 'mm', // default
      })

      const newUser = User({
        name: req.body.name,
        email: req.body.email,
        birthDate: moment(req.body.birthDate, 'DD/MM/YYYY'),
        password: req.body.password,
        profile,
      });

      bcryptHash(newUser.password)
        .then(hash => {
          newUser.password = hash;
github ging / fiware-idm / controllers / web / users.js View on Github external
}).then(function(user_registration) {
                        if (req.body.use_gravatar) {
                            var url = gravatar.url(user.email, {s:100, r:'g', d: 404}, {protocol: 'https'});

                            // Send an http request to gravatar
                            https.get(url, function(response) {
                                response.setEncoding('utf-8');
                                debug('  --> Request to gravatar status: ' + response.statusCode)
                                
                                // If exists set parameter in req.user
                                if (response.statusCode === 200) {
                                    models.user.update(
                                        { gravatar: true },
                                        {
                                            fields: ['gravatar'],
                                            where: {id: user.id}
                                        }
                                    ).then(function() {
                                        debug('  --> Gravatar set')
github webmodules / gravatar / test / index.js View on Github external
function printAvatar(email, opts){
  opts = opts || {};

  if (img) img.remove();
  body.addClass('loading');

  img = o(Grt.img(email, opts))
  .appendTo(img_ph)
  .on('load', function(){
    body.removeClass('loading');
  });

  profile_ph.empty();
  var profile = Grt.profile(email, function(err, data){
    var prts = [
      'displayName',
      'profileUrl',
      'id',
      'hash',
      'requestHash',
      'thumbnailUrl'
    ];
github webmodules / gravatar / test / index.js View on Github external
function printAvatar(email, opts){
  opts = opts || {};

  if (img) img.remove();
  body.addClass('loading');

  img = o(Grt.img(email, opts))
  .appendTo(img_ph)
  .on('load', function(){
    body.removeClass('loading');
  });

  profile_ph.empty();
  var profile = Grt.profile(email, function(err, data){
    var prts = [
      'displayName',
      'profileUrl',
      'id',
      'hash',
      'requestHash',
      'thumbnailUrl'
    ];

    for (var i = 0; i < prts.length; i++) {
      if (data[prts[i]]) {
        profile_ph.append(o('<p>').append(
          o('<span>', { text: prts[i] + ': ' }),
          o('<strong>', { text: data[prts[i]] })
        ));
      }</strong></span></p>
github sagefy / sagefy / server2 / database / users.js View on Github external
async function sendUserToEs(user) {
  return es.index({
    index: 'entity',
    type: 'user',
    body: {
      ...pick(user, ['id', 'created', 'name']),
      avatar: gravatar.url(user.email, { d: 'mm', s: '48' }),
    },
    id: user.id,
  })
}
github sagefy / sagefy / server2 / routes / users.js View on Github external
    avatars: users.map(user => gravatar.url(user.email, { d: 'mm', s: '48' })),
  })
github nilppm / npm / dist / service / web.js View on Github external
}
        const UserService = new this.service.UserService(this.ctx);
        const _user = await UserService.userCache(user.name).get({ account: user.name });
        if (_user) {
            if (_user.email === user.email)
                return {
                    name: _user.account,
                    email: _user.email,
                    avatar: _user.avatar,
                    nick: _user.name,
                };
        }
        return {
            name: user.name,
            email: user.email,
            avatar: gravatar_1.url(user.email),
            nick: user.name,
        };
    }
    async fixReadme(pathname, version) {
github xebia-france / xskillz-v2 / back / src / factory.js View on Github external
createUserUpdates: (userUpdates) => {
        var user = userUpdates[0];
        return {
            user: {
                name: user.user_name,
                id: user.user_id,
                gravatarUrl: gravatar.url(user.user_email),
                experienceCounter: user.user_diploma ? new Date().getFullYear() - new Date(user.user_diploma).getFullYear() : 0
            },
            updates: userUpdates.map((userUpdate)=> {
                return {
                    id: userUpdate.user_skill_id,
                    skill: {
                        id: userUpdate.skill_id,
                        interested: userUpdate.skill_interested[0] === 1,
                        level: userUpdate.skill_level,
                        name: userUpdate.skill_name
                    },
                    date: userUpdate.skill_date
                }
            })
        };
    },
github ging / fiware-idm / controllers / web / organizations.js View on Github external
users_organization.forEach(function(user) {
				if (users.length == 0 || !users.some(elem => (elem.id == user.User.id))) {
					if (user.User.gravatar) {
            			user.User.image = gravatar.url(user.User.email, {s:100, r:'g', d: 'mm'}, {protocol: 'https'});
					} else if (user.User.image == 'default') {
						user.User.image = '/img/logos/medium/user.png'
					} else {
						user.User.image = '/img/users/'+user.User.image
					}
					users.push(user.User)
				} 
			});
		}
github nilppm / npm / src / service / web.ts View on Github external
async formatUserAvatar(user?: { name: string, email?: string }): Promise&lt;{ name: string, email: string, avatar: string, nick: string }&gt; {
    if (!user || !user.name) {
      return {
        name: 'unknow',
        email: 'unknow@blank.com',
        avatar: url('unknow@blank.com'),
        nick: 'unknow',
      }
    }
    const UserService = new this.service.UserService(this.ctx);
    const _user = await UserService.userCache(user.name).get({ account: user.name });
    if (_user) {
      if (_user.email === user.email) return {
        name: _user.account,
        email: _user.email,
        avatar: _user.avatar,
        nick: _user.name,
      }
    }
    return {
      name: user.name,
      email: user.email,

gravatar

Gravatar Node.js library

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis