How to use the gravatar.url function in gravatar

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 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<{ name: string, email: string, avatar: string, nick: string }> {
    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,
github jo0ger / node-server / app / utils / gravatar.js View on Github external
return (email = '', opt = {}) => {
        if (!app.utils.validate.isEmail(email)) {
            return app.config.defaultAvatar
        }
        const protocol = `http${app.config.isProd ? 's' : ''}`
        const url = gravatar.url(email, Object.assign({
            s: '100',
            r: 'x',
            d: 'retro',
            protocol
        }, opt))
        return url && url.replace(`${protocol}://`, `${app.config.author.url}/proxy/`) || app.config.defaultAvatar
    }
}
github frogo / blog / controllers / app / comment.js View on Github external
if(!content.comments) {
                    content.comments = [];
                }
                content.comments.push(result._id);
                content.save();
                if(obj.reply) {
                    Comment.findById(obj.reply, function(err, comment) {
                        if(!comment.comments) {
                            comment.comments = [];
                        }
                        comment.comments.push(result._id);
                        comment.save();
                    });
                }
                let json = _.assign({}, _.pick(result, 'id', 'content', 'created', 'name', 'email', 'reply', 'from', 'ip'), {
                    avatar: gravatar.url(result.email || '', {s: '40',r: 'x',d: 'retro'}, true)
                });
                res.json({
                    success: true,
                    message: '评论成功',
                    data: json
                });
            });
        });

gravatar

Gravatar Node.js library

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis