From 4c33cee051fc4f697977abe3abbf3d269b33a1eb Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Fri, 5 Jul 2013 12:50:09 -0400 Subject: [PATCH] user restore for try.nodebb --- src/user.js | 2 +- src/webserver.js | 280 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 281 insertions(+), 1 deletion(-) diff --git a/src/user.js b/src/user.js index 71b18642d2..1adb0c65a4 100644 --- a/src/user.js +++ b/src/user.js @@ -66,7 +66,6 @@ var utils = require('./../public/src/utils.js'), if(data) { if(data['password']) delete data['password']; - data.uid = uid; } callback(data); } @@ -187,6 +186,7 @@ var utils = require('./../public/src/utils.js'), var gravatar = User.createGravatarURLFromEmail(email); RDB.hmset('user:'+uid, { + 'uid': uid, 'username' : username, 'userslug' : userslug, 'fullname': '', diff --git a/src/webserver.js b/src/webserver.js index 860130baca..a93c793947 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -329,6 +329,286 @@ var express = require('express'), },1); }); + + + app.get('/restoreusers', function(req, res) { + var users = [ + { + "lastposttime": "1371780880500", + "userslug": "frandroid", + "postcount": "2", + "joindate": "1371780652088", + "reputation": "2", + "picture": "http://www.gravatar.com/avatar/18c5b5c8f510b87137f791033faef29a?default=identicon", + "username": "frandroid", + "location": "", + "password": "$2a$10$aeIuMhHfMbfwD9vyfpmgSek.oJz0Awg6uYqRR9EfMVrEo1pltGriS", + "fullname": "", + "birthday": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "administrator": "0", + "gravatarpicture": "http://www.gravatar.com/avatar/18c5b5c8f510b87137f791033faef29a?default=identicon", + "email": "frandroid@gmail.com", + "uid": "4" + }, + { + "lastposttime": "1371844905163", + "userslug": "jmartins", + "postcount": "1", + "joindate": "1371844542588", + "reputation": "0", + "picture": "http://www.gravatar.com/avatar/61211955edb0f5ad1c4bf3d9d0d794c4?default=identicon", + "username": "jmartins", + "location": "", + "password": "$2a$10$1aRt1HbyCSxAi.Oozqs/U.9IaVn7e14BMLbKZFWRAOJScPA.2IuaK", + "fullname": "", + "birthday": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/61211955edb0f5ad1c4bf3d9d0d794c4?default=identicon", + "administrator": "0", + "email": "joao@nodeware.com.br", + "uid": "7" + }, + { + "lastposttime": "1372276794108", + "userslug": "julian", + "postcount": "4", + "joindate": "1371501794786", + "reputation": "1", + "picture": "http://www.gravatar.com/avatar/e1565907855fffe8433c31671a49f177?default=identicon", + "username": "julian", + "password": "$2a$10$guB.xWD30zA6MXW8qTjlW.I4mtRCWT8RzkaJlaiUErfbX9neUodQ2", + "location": "", + "birthday": "", + "fullname": "", + "uploadedpicture": "", + "website": "", + "signature": "Co-Founder, Design Create Play / NodeBB\nToronto, Ontario", + "administrator": "1", + "gravatarpicture": "http://www.gravatar.com/avatar/e1565907855fffe8433c31671a49f177?default=identicon", + "email": "julian@designcreateplay.com", + "uid": "2" + }, + { + "lastposttime": "1372296188180", + "userslug": "trevor", + "postcount": "7", + "joindate": "1372294776557", + "reputation": "1", + "picture": "http://www.gravatar.com/avatar/a0f06a0090e5367b55c1a8fb31c47513?default=identicon", + "username": "trevor", + "location": "", + "password": "$2a$10$wNL8cj31MlBrazPY92/AzeIs4WU6eBMVumriOFOyu2mtqdEVSOpni", + "fullname": "", + "birthday": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/a0f06a0090e5367b55c1a8fb31c47513?default=identicon", + "administrator": "0", + "email": "trevor4291@gmail.com", + "uid": "11" + }, + { + "lastposttime": "1372100797920", + "userslug": "dave", + "postcount": "1", + "joindate": "1372100717633", + "reputation": "0", + "picture": "http://www.gravatar.com/avatar/378b22e75617b070b80e52336aaa9d5c?default=identicon", + "username": "dave", + "location": "", + "password": "$2a$10$26D0Sccbl1qudOK2AEDWj.FvR3f3dsQUnk.xcLfS082S49xKuA5j.", + "fullname": "", + "birthday": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/378b22e75617b070b80e52336aaa9d5c?default=identicon", + "administrator": "0", + "email": "ddrager@xda-developers.com", + "uid": "9" + }, + { + "lastposttime": "1372297084849", + "userslug": "baris", + "postcount": "12", + "joindate": "1371501788271", + "reputation": "1", + "picture": "http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?default=identicon", + "username": "baris", + "password": "$2a$10$ZAQVjLKg2ev0sW6VCyq87O6LX5/z7d.uyIYWdM0kgIq7JKR/wCg1G", + "location": "Toronto, ON", + "birthday": "1983-02-18", + "fullname": "Baris Soner Usakli", + "uploadedpicture": "http://try.nodebb.org/uploads/1-black1.jpg", + "website": "http://baris.shadowytree.com", + "signature": "NodeBB Developer\nhttp://nodebb.org", + "gravatarpicture": "http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?default=identicon", + "email": "barisusakli@gmail.com", + "uid": "1" + }, + { + "lastposttime": "1372177299261", + "userslug": "psychobunny", + "postcount": "5", + "joindate": "1371567705241", + "reputation": "5", + "picture": "http://www.gravatar.com/avatar/ec001b26766105ea038160c98a317956?default=identicon", + "username": "psychobunny", + "password": "$2a$10$FmiNS8EDEB3m9IYnr4JF2eL/6L5h6TT0aegN1KItPD5MRrSFVDuR6", + "location": "", + "birthday": "", + "fullname": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/ec001b26766105ea038160c98a317956?default=identicon", + "email": "psycho.bunny@hotmail.com", + "uid": "3" + }, + { + "lastposttime": "0", + "birthday": "", + "fullname": "", + "postcount": "0", + "uploadedpicture": "", + "website": "", + "joindate": "1371843703632", + "signature": "", + "reputation": "0", + "administrator": "0", + "gravatarpicture": "http://www.gravatar.com/avatar/03a709deaf97ef4628f50634939f9d2e?default=identicon", + "picture": "http://www.gravatar.com/avatar/03a709deaf97ef4628f50634939f9d2e?default=identicon", + "username": "Pacem", + "email": "edausakli@gmail.com", + "password": "$2a$10$tmioEML3RgQkh7nf0XWAhePfN2xzDpX3jDaIzKvtsqffzohpo9ETa", + "location": "", + "userslug": "pacem", + "uid": "5" + }, + { + "lastposttime": "1371844356155", + "userslug": "alan", + "postcount": "2", + "joindate": "1371844234281", + "reputation": "0", + "picture": "http://www.gravatar.com/avatar/6350d3781efe9d1a3a88542771ee39d4?default=identicon", + "username": "alan", + "location": "", + "password": "$2a$10$GqQCo3.Xq0WHjbXYbttik.qKHe.AZIS/DJbmO3Iu2IwNjSrfcpW3.", + "fullname": "", + "birthday": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/6350d3781efe9d1a3a88542771ee39d4?default=identicon", + "administrator": "0", + "email": "alanhoffmeister@gmail.com", + "uid": "6" + }, + { + "lastposttime": "0", + "userslug": "prabhu", + "postcount": "0", + "joindate": "1372248496742", + "reputation": "0", + "picture": "http://www.gravatar.com/avatar/027fdebe8c66386e0805d9fe1647b3f6?default=identicon", + "username": "prabhu", + "location": "", + "password": "$2a$10$l.1flyAxiv1yJd9KDZz0xOZVPewCEavb1A6m3IySisI5PhNBKYwBC", + "fullname": "", + "birthday": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/027fdebe8c66386e0805d9fe1647b3f6?default=identicon", + "administrator": "0", + "email": "prabhu.sp@gmail.com", + "uid": "10" + }, + { + "postcount": "0", + "birthday": "", + "uploadedpicture": "", + "administrator": "0", + "email": "i@noformnocontent.com", + "lastposttime": "0", + "userslug": "nn", + "joindate": "1372952945584", + "reputation": "0", + "picture": "http://www.gravatar.com/avatar/a770385c11df2ff522891ff79fd0c8eb?default=identicon", + "username": "NN", + "location": "", + "password": "$2a$10$VyvNRROcowKo9CJ/PxG7F.utpO5rQAJuKyUftXImUlr6vqDU02N6O", + "fullname": "NN", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/a770385c11df2ff522891ff79fd0c8eb?default=identicon", + "uid": "13" + }, + { + "lastposttime": "1371937280069", + "userslug": "fabiolousmate", + "postcount": "1", + "joindate": "1371937199511", + "reputation": "0", + "picture": "http://www.gravatar.com/avatar/ad82efdfb33b2bb514ff1f3d9f32f7d1?default=identicon", + "username": "fabiolousmate", + "location": "", + "password": "$2a$10$AjsgEDOrkqO6In4f.I1eE.zVGPa.SK/z/YljzLjIHbGrjA8tesQy2", + "fullname": "", + "birthday": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/ad82efdfb33b2bb514ff1f3d9f32f7d1?default=identicon", + "administrator": "0", + "email": "fabio.barbieri@gmail.com", + "uid": "8" + }, + { + "lastposttime": "0", + "userslug": "test-test", + "postcount": "0", + "joindate": "1372303753517", + "reputation": "0", + "picture": "http://www.gravatar.com/avatar/5677dfcb7c7117b0ef64fc9897b861fb?default=identicon", + "username": "test test", + "location": "", + "password": "$2a$10$Gh9GsuROV.W8FDRKVdL7EOvpAxN24JsHD7MGWRx8R39wh6mP2YbXO", + "fullname": "", + "birthday": "", + "uploadedpicture": "", + "website": "", + "signature": "", + "gravatarpicture": "http://www.gravatar.com/avatar/5677dfcb7c7117b0ef64fc9897b861fb?default=identicon", + "administrator": "0", + "email": "test@test1.com", + "uid": "12" + } + ]; + + for(var user in users) { + redis.hmset('user:'+user.uid, user); + + RDB.set('username:' + user.username + ':uid', user.uid); + RDB.set('email:' + user.email +':uid', user.uid); + RDB.set('userslug:'+ user.userslug +':uid', user.uid); + + RDB.incr('usercount', function(err, count) { + RDB.handle(err); + }); + + RDB.lpush('userlist', user.username); + } + + res.send('success'); + }); //START TODO: MOVE TO GRAPH.JS