}else if(typeof(req.body.edit) != "undefined"){\r
async.waterfall([\r
function(cb){\r
- collection.UpdatAsync(req.body.name,req.body,cb);\r
- }\r
+ if(req.body.updatepw == false)\r
+ collection.UpdatAsync(req.body.name,req.body,null,cb);\r
+ else\r
+ collection.UpdatAsync(req.body.name,req.body,req.body.password,cb);\r
+ },\r
],function(err,result){\r
if(err != null)\r
RenderMessage(res,err,req.session.items);\r
pool.query("SELECT * FROM list WHERE name_hash = ? and name = ?",[murmurhash.v3(name),name],next);\r
},\r
function(result,next){\r
- if(result[0].password == password)\r
+ if(result[0].password == md5_hex(password))\r
next(null,true);\r
else\r
next(null,false);\r
height:data.height,\r
weight:data.weight,\r
race:data.race,\r
- password:data.password,\r
+ password:md5_hex(data.password),\r
lastmodified:new Date(),\r
etc:data.etc\r
};\r
pool.query("INSERT INTO list SET ?",[item],cb);\r
}\r
- this.UpdatAsync = function(name,data,cb){\r
+ this.UpdatAsync = function(name,data,newpassword,cb){\r
var item = {\r
name_hash:murmurhash.v3(data.name),\r
name:data.name,\r
height:data.height,\r
weight:data.weight,\r
race:data.race,\r
- password:data.password,\r
lastmodified:new Date(),\r
etc:data.etc\r
};\r
+ if(newpassword != null)\r
+ item.password = md5_hex(newpassword);\r
pool.query("UPDATE list SET ? WHERE name = ?",[item,name],cb);\r
}\r
this.ClearAsync = function(cb){\r
this.ToArrayAsync = function(start,count,cb){\r
pool.query("SELECT name,age,lastmodified FROM list LIMIT ?,?",[start,count],cb);\r
}\r
+\r
+ var crypto = require("crypto");\r
+ function md5_hex(src)\r
+ {\r
+ var md5 = crypto.createHash('md5');\r
+ md5.update(src, 'utf8');\r
+ return md5.digest('hex');\r
+ }\r
}\r
\r