Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aef93bb

Browse files
author
wmui
committed
fix: url
1 parent 1e3e463 commit aef93bb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

app/middleware/auth.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = redirect => {
1+
module.exports = redirectUrl => {
22
return async (ctx, next) => {
33
const Token = ctx.get('Token') || ctx.cookies.get('Token');
44
if (!Token) {
@@ -9,8 +9,8 @@ module.exports = redirect => {
99
if (data.status === 1) {
1010
await next();
1111
} else {
12-
if (redirect) {
13-
await ctx.redirect('/login');
12+
if (redirectUrl) {
13+
await ctx.redirect(redirectUrl);
1414
} else {
1515
ctx.body = {
1616
success: false,

app/router.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module.exports = app => {
1111
// 首页
1212
router.get('/', controller.post.list);
1313
router.get('/search', controller.post.list);
14-
router.get('/draft', auth(true), controller.post.draft);
14+
router.get('/draft', auth('/login'), controller.post.draft);
1515
// 编辑器
16-
router.get('/editor', auth(true), controller.post.editor);
16+
router.get('/editor', auth('/login'), controller.post.editor);
1717
// 文章详情页
1818
router.get('/post', controller.post.view);
1919
// 获取文章
@@ -39,7 +39,7 @@ module.exports = app => {
3939
// 初始化管理员
4040
router.post('/api/user', controller.user.init);
4141
// 设置
42-
router.get('/setting', auth(true), controller.option.setting);
42+
router.get('/setting', auth('/login'), controller.option.setting);
4343
// 修改或新增seo
4444
router.post('/api/seo', auth(), controller.option.saveSeo);
4545
router.get('/api/seo', auth(), controller.option.findSeo);
@@ -51,7 +51,7 @@ module.exports = app => {
5151
// 数据同步
5252
router.get('/api/cnblogs', controller.post.cnblogsSync);
5353
// 留言板
54-
router.get('/board', auth(true), controller.option.boardTmp);
54+
router.get('/board', auth('/board'), controller.option.boardTmp);
5555
router.post('/api/board', auth(), controller.option.boardSave);
5656
router.delete('/api/board/:id', auth(), controller.option.boardDel);
5757
// 其他

0 commit comments

Comments
 (0)