...
|
...
|
@@ -6,6 +6,9 @@ |
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const requestIp = require('request-ip');
|
|
|
const md5 = require('md5');
|
|
|
|
|
|
const _getGender = (channel) => {
|
|
|
switch (channel) {
|
|
|
case 'boys':
|
...
|
...
|
@@ -17,6 +20,21 @@ const _getGender = (channel) => { |
|
|
}
|
|
|
};
|
|
|
|
|
|
const udidRequired = (req, res, next) => {
|
|
|
let udid = req.cookies.udid;
|
|
|
|
|
|
if (!udid) {
|
|
|
udid = md5(req.ip || requestIp.getClientIp(req));
|
|
|
|
|
|
if (res && res.cookie) {
|
|
|
res.cookie('udid', udid);
|
|
|
}
|
|
|
|
|
|
req.user.udid = udid;
|
|
|
}
|
|
|
next();
|
|
|
};
|
|
|
|
|
|
module.exports = () => {
|
|
|
return (req, res, next) => {
|
|
|
let yoho = {
|
...
|
...
|
@@ -35,6 +53,21 @@ module.exports = () => { |
|
|
|
|
|
yoho.isApp = req.query.app_version || req.query.appVersion;
|
|
|
|
|
|
// uuid
|
|
|
yoho.udid = (function() {
|
|
|
let udid = req.cookies.udid;
|
|
|
|
|
|
if (!udid) {
|
|
|
udid = md5(req.ip || requestIp.getClientIp(req));
|
|
|
|
|
|
if (res && res.cookie) {
|
|
|
res.cookie('udid', udid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return udid;
|
|
|
}());
|
|
|
|
|
|
Object.assign(res.locals, yoho);
|
|
|
Object.assign(req.yoho, yoho);
|
|
|
next();
|
...
|
...
|
|