From 7d27a7c6d37747c4f48a622d7510d4ddf0ce1b1e Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli <barisusakli@gmail.com> Date: Thu, 9 May 2013 13:53:58 -0400 Subject: [PATCH] changed user update profile so that it only updates specific fields, before it was possible to send in rep,post count --- public/templates/accountedit.tpl | 4 ++-- src/user.js | 11 ++++++++--- src/webserver.js | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) 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('/'); });