Authored by xuqi

auth when shopping order

... ... @@ -8,6 +8,7 @@
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const auth = require(`${global.middleware}/auth`);
const cartCtrl = require(`${cRoot}/cart`); // 购物车
const order = require(`${cRoot}/order`); // 下单
... ... @@ -22,8 +23,8 @@ router.get('/cart/product/:productId/edit', cartCtrl.editProduct);
router.post('/cart/add', cartCtrl.addToCart);
// 结算
router.get('/order', order.index);
router.get('/order/compute', order.compute);
router.post('/order/submit', order.orderSub);
router.get('/order', auth, order.index);
router.get('/order/compute', auth, order.compute);
router.post('/order/submit', auth, order.orderSub);
module.exports = router;
... ...
... ... @@ -7,9 +7,9 @@
'use strict';
const _ = require('lodash');
const helpers = global.yoho.helper;
const helpers = global.yoho.helpers;
const required = (req, res, next) => {
module.exports = (req, res, next) => {
req.getUrl = function() {
return req.protocol + '://' + req.get('host') + req.originalUrl;
};
... ... @@ -20,7 +20,3 @@ const required = (req, res, next) => {
next();
};
module.exports = {
required
};
... ...