Skip to content
This repository was archived by the owner on Dec 30, 2018. It is now read-only.

Commit a86342b

Browse files
committed
v0.7.7, update user password
Signed-off-by: zensh <admin@zensh.com>
1 parent 3672de7 commit a86342b

16 files changed

+79
-18
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
node app.js --dev
1919

20+
**v0.7.7版 升级了账号密码系统,v0.7.6及之前的版本升级后需更新数据库,请运行 `node app.js update-passwd` **
21+
2022
### 简介 (Introduction)
2123

2224
[JsGen][1]是用纯JavaScript编写的新一代开源社区网站系统,主要用于搭建SNS类型的专业社区,对客户端AngularJS应用稍作修改也可变成多用户博客系统、论坛或者CMS内容管理系统。

app.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ serverDm.run(function () {
4747
jsGen.dao.collection = require('./dao/collectionDao.js');
4848

4949
jsGen.thenErrLog = function (defer, err) {
50+
console.error(err);
5051
jsGen.serverlog.error(err);
5152
};
5253

@@ -61,7 +62,6 @@ serverDm.run(function () {
6162
function exit() {
6263
redis.close();
6364
jsGen.dao.db.close();
64-
jsGen.serverlog.error(error);
6565
return process.exit(1);
6666
}
6767

@@ -74,6 +74,14 @@ serverDm.run(function () {
7474
return;
7575
}
7676

77+
// v0.7.5升级至v0.7.6 更新账号密码
78+
if (process.argv.indexOf('update-passwd') > 0) {
79+
require('./patch/passwd_0.7.5-0.7.6.js')().then(function () {
80+
return exit();
81+
}).fail(jsGen.thenErrLog);
82+
return;
83+
}
84+
7785
then.parallel([function (defer) {
7886
jsGen.dao.index.getGlobalConfig(defer);
7987
}, function (defer) {

dao/userDao.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ var that = jsGen.dao.db.bind('users', {
7373
}).each(callback);
7474
},
7575

76+
getFullUsersIndex: function (callback) {
77+
callback = callback || callbackFn;
78+
that.find({}, {
79+
sort: {
80+
_id: -1
81+
},
82+
hint: {
83+
_id: 1
84+
}
85+
}).each(callback);
86+
},
87+
7688
getLatestId: function (callback) {
7789
callback = callback || callbackFn;
7890
that.findOne({}, {
@@ -541,6 +553,7 @@ module.exports = {
541553
convertID: that.convertID,
542554
getUsersNum: that.getUsersNum,
543555
getUsersIndex: that.getUsersIndex,
556+
getFullUsersIndex: that.getFullUsersIndex,
544557
getLatestId: that.getLatestId,
545558
getAuth: that.getAuth,
546559
getSocial: that.getSocial,

lib/redis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function connect() {
4242
function close() {
4343
each(client, function (cli) {
4444
cli.end();
45-
})
45+
});
4646
}
4747

4848
function initConfig(configTpl, callback) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"url": "http://weibo.com/zensh"
66
},
77
"name": "jsgen",
8-
"version": "0.7.6",
8+
"version": "0.7.7",
99
"description": "",
1010
"keywords": ["Node.js", "AngularJS", "mongoDB", "jsGen"],
1111
"homepage": "https://github.com/zensh/jsgen",

patch/passwd_0.7.5-0.7.6.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
/*global require, module, Buffer, jsGen*/
3+
// v0.7.5升级至v0.7.6 更新账号密码
4+
var then = jsGen.module.then,
5+
HmacSHA256 = jsGen.lib.tools.HmacSHA256;
6+
7+
module.exports = function () {
8+
var count = 0, users = [], userDao = jsGen.dao.user;
9+
return then(function (defer) {
10+
var userDao = jsGen.dao.user;
11+
userDao.getFullUsersIndex(function (err, doc) {
12+
if (err) {
13+
defer(err);
14+
} else if (doc) {
15+
users.push(doc);
16+
} else {
17+
console.log(users.length + ' users need to update!');
18+
defer(null, users);
19+
}
20+
});
21+
}).each(null, function (defer, user) {
22+
var passwd = HmacSHA256(user.passwd, 'jsGen'),
23+
data = {
24+
_id: user._id,
25+
passwd: passwd
26+
};
27+
userDao.setUserInfo(data, function (error, user) {
28+
count += 1;
29+
console.log(count + ' : ' + user.name + ' updated.');
30+
defer(null, user);
31+
});
32+
}).then(function (defer, list) {
33+
console.log('Total ' + users.length + ' users, ' + list.length + ' users updated.');
34+
defer();
35+
});
36+
};

static/Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = function(grunt) {
3737
src: 'src/js/*.js'
3838
},
3939
server: {
40-
src: ['../app.js', '../app.js', '../api/*.js', '../dao/*.js', '../lib/*.js']
40+
src: ['../app.js', '../app.js', '../api/*.js', '../dao/*.js', '../lib/*.js', '../patch/*.js']
4141
}
4242
},
4343

static/bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsGen",
3-
"version": "0.7.5",
3+
"version": "0.7.7",
44
"main": "index.html",
55
"dependencies": {
66
"angular": ">=1.2.0",

static/dist/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<link rel="shortcut icon" href="http://cdn.angularjs.cn/favicon.ico"/>
1313
<link rel="stylesheet" href="http://cdn.angularjs.cn/css/jsgen.min.css?v=9513ac1c7029ce1ee7b19cd43c75e070">
1414
<link rel="stylesheet" href="http://cdn.angularjs.cn/css/font-awesome.min.css?v=fa6868c22ceca7f65191ec25c68a9bb5">
15-
<script src="http://cdn.angularjs.cn/js/reserveLoad.min.js?v=94924aac8b0e21c286d4d5d5c8cf2e1c"></script>
15+
<script src="http://cdn.angularjs.cn/js/reserveLoad.min.js?v=74909c4cc9a4f3b7d739701507027e9b"></script>
1616
</head>
1717
<!--[if lt IE 8]> <body class="ie pure-g-r"> <![endif]-->
1818
<!--[if gt IE 7]><!--> <body class="pure-g-r ng-cloak" ng-cloak> <!--<![endif]-->
@@ -72,11 +72,11 @@ <h1>AngularJS中文社区</h1>
7272
cdn = 'http://cdn.angularjs.cn/';
7373

7474
reserveLoad(
75-
IE8 && [cdn + 'js/ie.min.js?v=8439e6ad4b1308834f160aeae9ce7344', '/static/js/ie.min.js?v=8439e6ad4b1308834f160aeae9ce7344', 'JSON'], // load it if lt IE 9
75+
IE8 && [cdn + 'js/ie.min.js?v=05705f0fe7b1805a2179e9de544e2c0e', '/static/js/ie.min.js?v=05705f0fe7b1805a2179e9de544e2c0e', 'JSON'], // load it if lt IE 9
7676
[cdn + 'js/jquery.' + jqVer + '.js', '/static/js/jquery.' + jqVer + '.js', '$'],
77-
[cdn + 'js/angular-all.min.js?v=55bb3bb50cd3ab53352673b6026aff2f', '/static/js/angular-all.min.js?v=55bb3bb50cd3ab53352673b6026aff2f', 'angular'],
78-
[cdn + 'js/lib.min.js?v=5a028d8e1612728e88b0eab177c40b9a', '/static/js/lib.min.js?v=5a028d8e1612728e88b0eab177c40b9a', 'Sanitize'],
79-
[cdn + 'js/jsgen.min.js?v=09acf5e45fb6414c3d3a6684294556ef', '/static/js/jsgen.min.js?v=09acf5e45fb6414c3d3a6684294556ef', 'jsGen'],
77+
[cdn + 'js/angular-all.min.js?v=fecf9a082b25b129f313dda0b875fd08', '/static/js/angular-all.min.js?v=fecf9a082b25b129f313dda0b875fd08', 'angular'],
78+
[cdn + 'js/lib.min.js?v=0ff8ece699c22170d2fcabeedd8926bf', '/static/js/lib.min.js?v=0ff8ece699c22170d2fcabeedd8926bf', 'Sanitize'],
79+
[cdn + 'js/jsgen.min.js?v=57593fee0828c3bcd71fb137249fa236', '/static/js/jsgen.min.js?v=57593fee0828c3bcd71fb137249fa236', 'jsGen'],
8080
function (errorUrl) {
8181
if (errorUrl) {
8282
alert('Error loading: ' + errorUrl);

static/dist/js/angular-all.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)