From: konekoneko Date: Mon, 6 May 2013 07:46:25 +0000 (+0900) Subject: GetItem()でパスワード関連の処理を行うようにした X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=408d5520636d6752bacd841c435dc53f34147ed8;p=webchat%2FWebChat.git GetItem()でパスワード関連の処理を行うようにした --- diff --git a/profile.js b/profile.js index f42a1ee..5c10efc 100644 --- a/profile.js +++ b/profile.js @@ -293,9 +293,7 @@ function ProfileCollection() pool.query("INSERT INTO profilelist SET ?",[item],cb); } this.UpdatAsync = function(name,data,newpassword,cb){ - var item = GetItem(data); - if(newpassword != null) - item.password = md5_hex(newpassword); + var item = GetItem(data,newpassword); pool.query("UPDATE profilelist SET ? WHERE name = ?",[item,name],cb); } this.ClearAsync = function(cb){ @@ -322,7 +320,7 @@ function ProfileCollection() return md5.digest('hex'); } - function GetItem(data) + function GetItem(data,newpw) { var item = { name_hash:murmurhash.v3(data.name), @@ -330,17 +328,23 @@ function ProfileCollection() }; for(var key in config.alias) { - if(key == "password") + if(config.alias[key].visible_edit) { - item[key] = md5_hex(data[key]); - } - else if(config.alias[key].visible_edit) - { - console.log("name:"+key+" data:"+data[key]); - if(data[key] == "" && typeof(config.alias[key].defaultvalue) != "undefined") + if(config.alias[key].type == "password") + { + if(typeof(newpw) != "undefined") + data[key] = newpw; + if(data[key] != null) + item[key] = md5_hex(data[key]); + } + else if(data[key] == "" && typeof(config.alias[key].defaultvalue) != "undefined") + { item[key] = config.alias[key].defaultvalue; + } else + { item[key] = data[key]; + } } } return item;