Authored by xuqi

auth when shopping order

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