浏览代码

维护判断bug修复

laiguoran 5 年之前
父节点
当前提交
762021c6f0
共有 2 个文件被更改,包括 11 次插入3 次删除
  1. 5 0
      app/middleware/session_auth.js
  2. 6 3
      app/service/maintain.js

+ 5 - 0
app/middleware/session_auth.js

@@ -38,6 +38,9 @@ module.exports = options => {
             yield this.service.notify.syncNotifyData();
             // 同步系统维护信息
             yield this.service.maintain.syncMaintainData();
+            if (this.session === null) {
+                throw '系统维护中~';
+            }
         } catch (error) {
             console.log(error);
             if (this.helper.isAjax(this.request)) {
@@ -46,6 +49,8 @@ module.exports = options => {
                     msg: '登录信息异常,请重新登录',
                     data: '',
                 };
+            } else if (this.session === null) {
+                return this.redirect('/login?referer=' + this.url);
             } else {
                 this.session.message = {
                     type: messageType.ERROR,

+ 6 - 3
app/service/maintain.js

@@ -48,6 +48,10 @@ module.exports = app => {
                     }
                 }
                 if (maintainData.status === status) {
+                    if (status === maintainConst.status.ongoing && this.ctx.session !== null) {
+                        this.ctx.session = null;
+                        throw '系统维护中~';
+                    }
                     return true;
                 }
                 const data = {};
@@ -57,10 +61,9 @@ module.exports = app => {
                     data.maintain_time = '';
                 }
                 const operate = this.db.update(this.tableName, data);
-
-                if (status === maintainConst.status.ongoing) {
+                if (status === maintainConst.status.ongoing && this.ctx.session !== null) {
                     this.ctx.session = null;
-                    this.ctx.redirect('/');
+                    throw '系统维护中~';
                 }
 
                 result = operate.affectedRows > 0;