Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.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;
}).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')
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'
];
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>
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,
})
}
avatars: users.map(user => gravatar.url(user.email, { d: 'mm', s: '48' })),
})
}
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) {
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
}
})
};
},
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)
}
});
}
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,