• This project
    • Loading...
  • Sign in

fe / yohobuywap-node · Files

Go to a project

GitLab

  • Go to group
  • Project
  • Activity
  • Files
  • Commits
  • Pipelines 0
  • Builds 0
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Members
  • Labels
  • Wiki
  • Forks
  • Network
  • Create a new issue
  • yohobuywap-node
  • doraemon
  • middleware
  • req-params-filter.js
  • black-list
    287a3dbb
    by 郭成尧
    2017-01-05 15:23:26 +0800  
    Browse Files
req-params-filter.js 537 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
const _ = require('lodash');

// 黑名单参数
const BLACK_LIST = [
    'client_secret',
    'method',
    'openby:yohobuy'
];

module.exports = () => {
    return (req, res, next) => {
        if (req.query) {
            _.forEach(BLACK_LIST, (key) => {
                if (key === 'client_secret') {
                    req.yoho.client_secret = req.query[key];
                }

                if (req.query[key]) {
                    delete req.query[key];
                }
            });
        }

        next();
    };
};