user.js
367 Bytes
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;
delete req.cookies._YOHOUID;
}
next();
};
};