Skip to content

Node.js based forum software built for the modern web

changed user update profile so that it only updates specific fields, before it was possible to send in rep,post count

Baris Soner Usakli7d27a7c6d377
diff --git a/public/templates/accountedit.tpl b/public/templates/accountedit.tpl
index 63f393e5db..9b931bfe16 100644
--- a/public/templates/accountedit.tpl
+++ b/public/templates/accountedit.tpl
@@ -76,7 +76,7 @@
$(document).ready(function(){
$('#submitBtn').on('click',function(){
- alert('click');
+
var userData = {
uid:$('#inputUID').val(),
email:$('#inputEmail').val(),
@@ -89,7 +89,7 @@
$.post('/edituser',
userData,
function(data) {
- alert('fail');
+
}
);
diff --git a/src/user.js b/src/user.js
index 09d87214f7..74acb2a48e 100644
--- a/src/user.js
+++ b/src/user.js
@@ -70,10 +70,15 @@ var config = require('../config.js'),
});
}
- User.updateUserFields = function(uid, data) {
+ User.updateProfile = function(uid, data) {
- for(var key in data) {
- User.setUserField(uid, key, data[key]);
+ var fields = ['email', 'fullname', 'website', 'location', 'birthday'];
+ var key = '';
+
+ for(var i=0,ii=fields.length; i<ii; ++i) {
+ key = fields[i];
+ if(data[key] !== undefined)
+ User.setUserField(uid, key, data[key]);
}
}
diff --git a/src/webserver.js b/src/webserver.js
index 702c0abb08..8629854f59 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -207,7 +207,7 @@ var express = require('express'),
if(req.user.uid != req.body.uid)
return res.redirect('/');
- user.updateUserFields(req.user.uid, req.body);
+ user.updateProfile(req.user.uid, req.body);
res.redirect('/');
});