Authored by htoooth

fix error

... ... @@ -69,18 +69,7 @@ passport.use('local', new LocalStrategy({
if (result.code && result.code === 200 && result.data.uid) {
cache.del(errorLoginKey).catch(() => {});
let uid = {
toString() {
return this.uid;
},
uid: result.data.uid,
sessionKey: result.data.session_key,
isValid() {
return this.uid && this.sessionKey;
}
};
done(null, {uid, session_key: result.data.session_key});
done(null, result.data);
} else {
errLoginTimes = errLoginTimes + 1;
accountTimes = accountTimes + 1;
... ...
... ... @@ -212,18 +212,7 @@ const bind = {
sourceType: sourceType + '_bind'
});
let uid = {
toString() {
return this.uid;
},
uid: result.data.uid,
sessionKey: result.data.session_key,
isValid() {
return this.uid && this.sessionKey;
}
};
return loginService.syncUserSession(uid, req, res, result.data.session_key).then(() => {
return loginService.syncUserSession(result.data.uid, req, res, result.data.session_key).then(() => {
return {code: 200, message: result.message, data: {refer: refer}};
});
} else {
... ... @@ -257,18 +246,7 @@ const bind = {
sourceType: sourceType + '_relate'
});
let uid = {
toString() {
return this.uid;
},
uid: result.data.uid,
sessionKey: result.data.session_key,
isValid() {
return this.uid && this.sessionKey;
}
};
return loginService.syncUserSession(uid, req, res, result.data.session_key).then(() => {
return loginService.syncUserSession(result.data.uid, req, res, result.data.session_key).then(() => {
return {code: 200, message: result.message, data: {refer: refer}};
});
} else {
... ...
... ... @@ -67,18 +67,7 @@ function doPassportCallback(req, res, user) {
});
} else if (result.data['is_bind'] === 'Y' && result.data.uid) {//eslint-disable-line
let uid = {
toString() {
return this.uid;
},
uid: result.data.uid,
sessionKey: result.data.session_key,
isValid() {
return this.uid && this.sessionKey;
}
};
return loginService.syncUserSession(uid, req, res, result.data.session_key).then(() => {
return loginService.syncUserSession(result.data.uid, req, res, result.data.session_key).then(() => {
return refer;
});
}
... ...
... ... @@ -273,18 +273,7 @@ let mobileRegister = (req, res, next) => {
return res.json(data);
}
let uid = {
toString() {
return this.uid;
},
uid: result.data.uid,
sessionKey: result.data.session_key,
isValid() {
return this.uid && this.sessionKey;
}
};
return loginService.syncUserSession(uid, req, res, regResult.data.session_key).then(() => {
return loginService.syncUserSession(regResult.data.uid, req, res, regResult.data.session_key).then(() => {
return res.json({
code: 200,
message: '注册成功',
... ...
... ... @@ -37,10 +37,21 @@ const syncUserSession = (uid, req, res, sessionKey) => {
});
}
let uidObj = {
toString() {
return this.uid;
},
uid: uid,
sessionKey: sessionKey,
isValid() {
return this.uid && this.sessionKey;
}
};
return Promise.all([
userService.profile(uid),
cartService.goodsCount(uid),
userService.checkNoCertEmailUser(uid).catch(err => logger(`checkNoCertEmailUser${uid}err: ${err}`))
userService.profile(uidObj),
cartService.goodsCount(uidObj),
userService.checkNoCertEmailUser(uidObj).catch(err => logger(`checkNoCertEmailUser${uid}err: ${err}`))
]).spread((userInfo, count, isTipCert) => {
let salt = uuid.v4().substr(0, 8);
let saltedUid = uid + salt;
... ...