|
|
|
@ -339,20 +339,29 @@ passport.deserializeUser(function(uid, done) {
|
|
|
|
|
return res.redirect('/403');
|
|
|
|
|
|
|
|
|
|
var requestedUserId = req.user.uid;
|
|
|
|
|
|
|
|
|
|
if(req.params.id != req.user.uid)
|
|
|
|
|
requestedUserId = req.params.id;
|
|
|
|
|
|
|
|
|
|
user.getUserData(requestedUserId, function(data) {
|
|
|
|
|
if(data)
|
|
|
|
|
{
|
|
|
|
|
data.joindate = utils.relativeTime(data.joindate);
|
|
|
|
|
data.uid = requestedUserId;
|
|
|
|
|
callback({user:data});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
callback({user:{}});
|
|
|
|
|
|
|
|
|
|
var username = req.params.id;
|
|
|
|
|
|
|
|
|
|
user.get_uid_by_username(username, function(uid) {
|
|
|
|
|
|
|
|
|
|
if(uid != req.user.uid)
|
|
|
|
|
requestedUserId = uid;
|
|
|
|
|
|
|
|
|
|
user.getUserData(requestedUserId, function(data) {
|
|
|
|
|
if(data)
|
|
|
|
|
{
|
|
|
|
|
data.joindate = utils.relativeTime(data.joindate);
|
|
|
|
|
data.uid = requestedUserId;
|
|
|
|
|
callback({user:data});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
callback({user:{}});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -387,27 +396,27 @@ passport.deserializeUser(function(uid, done) {
|
|
|
|
|
return res.redirect('/403');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.get('/users/:uid', handleUserProfile);
|
|
|
|
|
app.get('/users/:uid/:username*', handleUserProfile);
|
|
|
|
|
|
|
|
|
|
app.get('/users/:username*', handleUserProfile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handleUserProfile(req, res) {
|
|
|
|
|
console.log("OPPA 1");
|
|
|
|
|
if(req.params.uid == 0) {
|
|
|
|
|
|
|
|
|
|
if(!req.params.username) {
|
|
|
|
|
res.send("User doesn't exist!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user.getUserData(req.params.uid, function(data) {
|
|
|
|
|
if(data) {
|
|
|
|
|
if(req.url.indexOf(data.username) == -1)
|
|
|
|
|
res.redirect(301, '/users/'+req.params.uid+'/'+data.username);
|
|
|
|
|
else
|
|
|
|
|
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/' + req.params.uid +'/'+data.username + '");});</script>' + templates['footer']);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
res.send("User doesn't exist! /users/"+req.params.uid);
|
|
|
|
|
}
|
|
|
|
|
user.get_uid_by_username(req.params.username, function(uid) {
|
|
|
|
|
|
|
|
|
|
user.getUserData(uid, function(data) {
|
|
|
|
|
if(data) {
|
|
|
|
|
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/'+data.username + '");});</script>' + templates['footer']);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
res.send("User doesn't exist! /users/"+req.params.username);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|