|
|
|
@ -91,9 +91,20 @@ var user = require('./../user.js'),
|
|
|
|
|
if(!req.user)
|
|
|
|
|
return res.redirect('/403');
|
|
|
|
|
|
|
|
|
|
if(req.files.userPhoto.size > 131072) {
|
|
|
|
|
if(req.files.userPhoto.size > 262144) {
|
|
|
|
|
res.send({
|
|
|
|
|
error: 'Images must be smaller than 128kb!'
|
|
|
|
|
error: 'Images must be smaller than 256kb!'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'];
|
|
|
|
|
var type = req.files.userPhoto.type;
|
|
|
|
|
|
|
|
|
|
console.log(req.files.userPhoto);
|
|
|
|
|
|
|
|
|
|
if(allowedTypes.indexOf(type) === -1) {
|
|
|
|
|
res.send({
|
|
|
|
|
error: 'Allowed image types are png, jpg and gif!'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -152,6 +163,17 @@ var user = require('./../user.js'),
|
|
|
|
|
user.setUserField(uid, 'uploadedpicture', imageUrl);
|
|
|
|
|
user.setUserField(uid, 'picture', imageUrl);
|
|
|
|
|
|
|
|
|
|
var im = require('node-imagemagick');
|
|
|
|
|
|
|
|
|
|
im.resize({
|
|
|
|
|
srcPath: global.configuration['ROOT_DIRECTORY'] + uploadPath,
|
|
|
|
|
dstPath: global.configuration['ROOT_DIRECTORY'] + uploadPath,
|
|
|
|
|
width: 128
|
|
|
|
|
}, function(err, stdout, stderr){
|
|
|
|
|
if (err)
|
|
|
|
|
throw err;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
os.on('error', function(err) {
|
|
|
|
@ -244,16 +266,17 @@ var user = require('./../user.js'),
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
getUserDataByUserName(req.params.username, callerUID, function(userData) {
|
|
|
|
|
user.isFriend(callerUID, userData.theirid, function(isFriend) {
|
|
|
|
|
userData.isFriend = isFriend;
|
|
|
|
|
res.send(JSON.stringify(userData));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.get('/api/users/:username?/:section?', api_method);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getUserDataByUserName(username, callerUID, callback) {
|
|
|
|
|
|
|
|
|
|
user.get_uid_by_username(username, function(uid) {
|
|
|
|
|