Skip to content

Commit 314773f

Browse files
committed
Revert "新用户accessToken缺失;topic展示的边缘条件兼容"
This reverts commit cf0f5ed.
1 parent cf0f5ed commit 314773f

File tree

6 files changed

+7
-50
lines changed

6 files changed

+7
-50
lines changed

app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
var uuid = require('node-uuid');
32

43
module.exports = app => {
54
if (app.config.debug) {
@@ -47,7 +46,6 @@ module.exports = app => {
4746
existUser = new ctx.model.User();
4847
existUser.githubId = profile.id;
4948
existUser.active = true;
50-
existUser.accessToken = uuid.v4();
5149
}
5250

5351
// 用户存在,更新字段
@@ -63,7 +61,7 @@ module.exports = app => {
6361
if (ex.message.indexOf('duplicate key error') !== -1) {
6462
let err;
6563
if (ex.message.indexOf('email') !== -1) {
66-
err = new Error('您 GitHub 账号的 Email 与之前在 CNodejs 注册的 Email 重复了');
64+
err = new Error('您 GitHub 账号的 Email 与之前在 CNodejs 注册的用户名重复了');
6765
err.code = 'duplicate_email';
6866
throw err;
6967
}
@@ -125,4 +123,3 @@ module.exports = app => {
125123
return user;
126124
});
127125
};
128-

app/controller/topic.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ class TopicController extends Controller {
3131

3232
const [ topic, author, replies ] = await service.topic.getFullTopic(topic_id);
3333

34-
if (!topic) {
35-
ctx.status = 404;
36-
ctx.message = '此话题不存在或已被删除。';
37-
return;
38-
}
39-
4034
// 增加 visit_count
4135
topic.visit_count += 1;
4236
// 写入 DB

app/router.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = app => {
2929
router.post('/signup', createUserLimit, sign.signup);
3030
} else {
3131
// 进行github验证
32-
router.redirect('/signup', '/passport/github');
32+
router.redirect('/singup', '/auth/github');
3333
}
3434

3535
const localStrategy = app.passport.authenticate('local', {
@@ -43,9 +43,7 @@ module.exports = app => {
4343
router.get('/active_account', sign.activeAccount); // 帐号激活
4444

4545
// github oauth
46-
const github = app.passport.authenticate('github');
47-
app.get('/passport/github', github);
48-
app.get('/passport/github/callback', github);
46+
app.passport.mount('github');
4947

5048
router.get('/search_pass', sign.showSearchPass); // 找回密码页面
5149
router.post('/search_pass', sign.updateSearchPass); // 更新密码
@@ -110,4 +108,3 @@ module.exports = app => {
110108

111109
router.get('/search', search.index);
112110
};
113-

app/service/reply.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,21 @@ class ReplyService extends Service {
5252
*/
5353
async getRepliesByTopicId(id) {
5454
const query = { topic_id: id, deleted: false };
55-
let replies = await this.ctx.model.Reply.find(query, '', {
55+
const replies = await this.ctx.model.Reply.find(query, '', {
5656
sort: 'create_at',
5757
}).exec();
5858

5959
if (replies.length === 0) {
6060
return [];
6161
}
6262

63-
replies = replies.filter(function (item) {
64-
return !item.content_is_html
65-
})
66-
6763
return Promise.all(
6864
replies.map(async item => {
6965
const author = await this.service.user.getUserById(item.author_id);
7066
item.author = author || { _id: '' };
71-
67+
if (item.content_is_html) {
68+
return;
69+
}
7270
item.content = await this.service.at.linkUsers(item.content);
7371
return item;
7472
})

bin/generate_access_token.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"loader-koa": "^2.0.1",
2323
"lodash": "^4.17.5",
2424
"markdown-it": "^8.4.1",
25-
"node-uuid": "^1.4.8",
2625
"nodemailer": "^4.6.2",
2726
"nodemailer-smtp-transport": "^2.7.4",
2827
"qiniu": "^7.1.3",
@@ -47,7 +46,6 @@
4746
"scripts": {
4847
"start": "egg-scripts start --daemon --title=egg-server-cnode",
4948
"stop": "egg-scripts stop --title=egg-server-cnode",
50-
"restart": "npm run stop && npm run start",
5149
"docker": "egg-scripts start --title=egg-server-cnode",
5250
"dev": "egg-bin dev",
5351
"debug": "egg-bin debug",

0 commit comments

Comments
 (0)