Authored by yyq

fix login refer

... ... @@ -168,9 +168,25 @@ const login = {
},
taobaoCallback(req, res, next) {
passport.authenticate('taobao', (err, user) => {
let redirectUrl = loginPage;
let referUrl = {};
let refer;
if (req.cookies.ali_backurl) {
try {
referUrl = JSON.parse(req.cookies.ali_backurl);
} catch(e) {
log.debug(JSON.stringify(e));
}
refer = handleReferUrl(referUrl.b || '');
}
redirectUrl += '?nodownload=1&refer=' + encodeURIComponent(refer || homePage);
if (err || !user) {
log.error(`[authenticate error] source_type: taobao | err: ${JSON.stringify(err)}`);
return res.redirect(loginPage);
return res.redirect(redirectUrl);
}
const model = req.ctx(passportModel);
... ... @@ -180,19 +196,6 @@ const login = {
sourceType: 'taobao',
sourceTypeSecond: req.yoho.isAliApp ? 'xianyu' : ''
}).then(result => {
let redirectUrl = loginPage;
let referUrl = {};
if (req.cookies.ali_backurl) {
try {
referUrl = JSON.parse(req.cookies.ali_backurl);
} catch(e) {
log.debug(JSON.stringify(e));
}
redirectUrl += '?refer=' + encodeURIComponent(handleReferUrl(referUrl.b || ''));
}
if (result.code === 200) {
if (_.get(result, 'data.is_bind') === 'N') {
redirectUrl = referUrl.b ? referUrl.b : homePage;
... ...