changed profile page to /users/username

v1.18.x
Baris Usakli 12 years ago
parent 0eacec8166
commit cef1ba4c08

@ -59,7 +59,7 @@
gravatar.src = data['picture']+"?s=24";
$('#user_label').attr('href','/users/'+data.uid+'/'+data['username']);
$('#user_label').attr('href','/users/'+data['username']);
user_label.innerHTML = '';
user_label.appendChild(gravatar);

@ -340,8 +340,12 @@ passport.deserializeUser(function(uid, done) {
var requestedUserId = req.user.uid;
if(req.params.id != req.user.uid)
requestedUserId = req.params.id;
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)
@ -353,6 +357,11 @@ passport.deserializeUser(function(uid, done) {
else
callback({user:{}});
});
});
}
@ -387,28 +396,28 @@ 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) {
user.get_uid_by_username(req.params.username, function(uid) {
user.getUserData(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']);
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.uid);
res.send("User doesn't exist! /users/"+req.params.username);
}
});
});
}

Loading…
Cancel
Save