...
|
...
|
@@ -7,6 +7,7 @@ |
|
|
|
|
|
const library = '../../../library';
|
|
|
const passport = require('passport');
|
|
|
const md5 = require('md5');
|
|
|
const cookie = require(`${library}/cookie`);
|
|
|
const helpers = require(`${library}/helpers`);
|
|
|
const log = require(`${library}/logger`);
|
...
|
...
|
@@ -51,6 +52,47 @@ function doPassportCallback(openId, nickname, sourceType, req, res) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
const local = {
|
|
|
loginPage: (req, res) => {
|
|
|
// 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
|
|
|
res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800);
|
|
|
|
|
|
// 清除cookie
|
|
|
res.clearCookie('_UID');
|
|
|
res.clearCookie('_TOKEN');
|
|
|
|
|
|
let refer = req.query.refer;
|
|
|
|
|
|
if (!refer) {
|
|
|
refer = req.get('Referer');
|
|
|
}
|
|
|
refer && res.cookie('refer', encodeURI(refer), {
|
|
|
domain: 'yohobuy.com'
|
|
|
});
|
|
|
|
|
|
res.render('login', {
|
|
|
loginIndex: true, // 模板中使用JS的标识
|
|
|
backUrl: 'javascript:history.go(-1)', // 返回的URL链接
|
|
|
showHeaderImg: true, // 控制显示头部图片
|
|
|
isPassportPage: true, // 模板中模块标识
|
|
|
registerUrl: '/reg.html', // 注册的URL链接
|
|
|
aliLoginUrl: '/passport/login/alipay', // 支付宝快捷登录的URL链接
|
|
|
weiboLoginUrl: '/passport/login/sina', // 微博登录的URL链接
|
|
|
qqLoginUrl: '/passport/login/qq', // 腾讯QQ登录的URL链接
|
|
|
internationalUrl: '/login.html', // 国际号登录的URL链接
|
|
|
phoneRetriveUrl: '/passport/back/mobile', // 通过手机号找回密码的URL链接
|
|
|
emailRetriveUrl: '/passport/back/email', // 通过邮箱找回密码的URL链接
|
|
|
module: 'passport',
|
|
|
page: 'index',
|
|
|
title: '登录'
|
|
|
});
|
|
|
},
|
|
|
login: (req, res, next) => {
|
|
|
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const wechat = {
|
|
|
beforeLogin: (req, res, next) => {
|
|
|
let refer = req.query.refer;
|
...
|
...
|
@@ -80,4 +122,5 @@ const wechat = { |
|
|
}
|
|
|
};
|
|
|
|
|
|
exports.local = local;
|
|
|
exports.wechat = wechat; |
...
|
...
|
|