1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- const { verify } = require('jsonwebtoken');
- const { isProd, jwtSecretBusin } = require('../config');
- const { onError } = require('../utils');
- module.exports = () => {
- return (req, res, next) => {
- if (/^\/(login)?\/?$/.test(req.path)) {
- return next();
- }
- // console.log(req.originalUrl);
- // const { token } = req.cookies;
- // // console.log(req.headers);
- // // console.log(token);
- // if (token) {
- // req.admin = verify(token, jwtSecretAdmin);
- // // console.log(req.user);
- // return next();
- // }
- if (req.path.includes('phone_login')) {
- return next();
- }
- if (req.path.includes('sms')) {
- return next();
- }
- console.log(req.path);
- if (req.path === '/clue/home') {
- return next();
- }
- if (req.path.includes('problem')) {
- return next();
- }
- console.log(1);
- console.log(req.session);
- console.log(req);
- console.log(req.headers);
- const bus = req.session.business;
- if (bus) {
- req.business = bus;
- console.log(3);
- return next();
- }
- // if (!isProd() && !req.business && !req.hostname.includes('fuxicarbon')) {
- if (!isProd() && !req.business) {
- console.log(2);
- req.business = {
- id: 10000,
- };
- return next();
- }
- return res.send(onError('用户错误'));
- };
- };
|