• This project
    • Loading...
  • Sign in

fe / yohoblk-wap · 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
  • yohoblk-wap
  • doraemon
  • middleware
  • user.js
  • add uid check
    716e6e3e
    by ccbikai
    2016-07-26 11:35:32 +0800  
    Browse Files
user.js 326 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
const md5 = require('yoho-md5');

module.exports = () => {
    return (req, res, next) => {
        const uid = req.cookies._YOHOUID;
        const token = req.cookies._YOHOTOKEN;
        const key = `-_-!!!${uid}!!!-_-`;

        if (md5(key) === token) {
            req.user.uid = uid;
        }

        next();
    };
};