| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | 'use strict';/** * * @author LanJianRong * @date  2021-12-27 * @version */const maintainConst = require('../const/maintain');const sign = require('../const/sign');const jwt = require('jsonwebtoken');module.exports = options => {    return function* api3managementCheck(next) {        try {            // 获取系统维护信息            const maintainData = yield this.service.maintain.getDataById(1);            if (maintainData.status === maintainConst.status.ongoing) {                throw '系统维护中~';            }            const token = this.query.auth;            if (!token) {                throw '参数有误';            }            try {                const decoded = jwt.verify(token, sign.managementApiSecretKey);                if (!decoded.data) throw '参数有误';                this.data = decoded.data;            } catch (error) {                throw error;            }            // const data = yield this.service.project.getProjectByCode(code.toString().trim());            // if (data === null) {            //     throw '不存在项目数据';            // }            // if (data.custom === 0) {            //     throw '无法通过接口登录本系统';            // }            // if (data.custom === 1 && data.can_api === 0) {            //     throw '接口已关闭,无法使用';            // }            // const encryptSign = crypto.createHash('md5').update(data.code + data.secret + time.toString()).digest('hex').toString();            // if (encryptSign !== sign) {            //     throw '参数验证失败';            // }            // this.projectData = data;            yield next;        } catch (err) {            this.body = {                code: -1,                msg: err.toString(),                data: null,            };            return;        }    };};
 |