user edit changes

v1.18.x
Baris Usakli 12 years ago
parent 0210e5a928
commit 9166a9ccde

@ -10,7 +10,7 @@
<div class="account-username-box">
<span class="account-username"><a href="/users/{user.username}">{user.username}</a></span>
<span class="pull-right"><a href="/users/{user.username}/edit">edit</a></span>
<span id="editLink" class="pull-right"><a href="/users/{user.username}/edit">edit</a></span>
</div>
<div class="account-picture-block">
@ -50,13 +50,17 @@
<span id='postcount'>{user.postcount}</span>
</div>
<!-- END user -->
</div>
<script type="text/javascript">
var yourid = '{yourid}';
var theirid = '{theirid}';
(function() {
function addCommas(text) {
@ -70,6 +74,10 @@
var postcount = $('#postcount');
postcount.html(addCommas(postcount.html()));
var editLink = $('#editLink');
if( yourid !== theirid)
editLink.addClass('hidden');
});

@ -57,6 +57,8 @@
</div>
</div>
<input type="hidden" id="inputUID" value="{user.uid}">
<div class="form-actions">
<a id="submitBtn" href="" class="btn btn-primary">Save changes</a>
<a href="/users/{user.username}" class="btn">Cancel</a>
@ -76,6 +78,7 @@
$('#submitBtn').on('click',function(){
var userData = {
uid:$('#inputUID').val(),
email:$('#inputEmail').val(),
fullname:$('#inputFullname').val(),
website:$('#inputWebsite').val(),

@ -70,7 +70,7 @@ var config = require('../config.js'),
}
User.updateUserFields = function(uid, data) {
console.log(data);
for(var key in data) {
User.setUserField(uid, key, data[key]);
}

@ -228,7 +228,7 @@ passport.deserializeUser(function(uid, done) {
else if (String(req.params.section).toLowerCase() === 'edit') {
get_account_fn(req, res, function(userData) {
res.send(JSON.stringify(userData));
});
});
} else {
get_account_fn(req, res, function(userData) {
res.send(JSON.stringify(userData));
@ -334,10 +334,11 @@ passport.deserializeUser(function(uid, done) {
app.post('/edituser', function(req, res){
if(!req.user) {
res.redirect('/403');
return;
}
if(!req.user)
return res.redirect('/403');
console.log(req.body.uid);
if(req.user.uid !== req.body.uid)
return res.redirect('/');
user.updateUserFields(req.user.uid, req.body);
@ -377,7 +378,11 @@ passport.deserializeUser(function(uid, done) {
data.joindate = utils.relativeTime(data.joindate);
data.age = new Date().getFullYear() - new Date(data.birthday).getFullYear();;
data.uid = uid;
callback({user:data});
callback({
yourid:req.user.uid,
theirid:uid,
user:data
});
}
else
callback({user:{}});

Loading…
Cancel
Save