fix: 修改第三方登陆出现的bug

This commit is contained in:
gaoxiaolin.gao 2018-07-19 11:53:08 +08:00
parent 826c7c69f1
commit d8571f07c9

View File

@ -142,8 +142,8 @@ class userController extends baseController {
const emailParams = ldapInfo[yapi.WEBCONFIG.ldapLogin.emailKey || 'mail'] || (emailPostfix ? emailPrefix + yapi.WEBCONFIG.ldapLogin.emailPostfix : email);
const username = ldapInfo['name'];
let login = await this.handleThirdLogin(emailParams, username);
if (login === true) {
let userInst = yapi.getInst(userModel); //创建user实体
let result = await userInst.findByEmail(emailParams);
@ -155,7 +155,7 @@ class userController extends baseController {
email: result.email,
add_time: result.add_time,
up_time: result.up_time,
type: 'third',
type: result.type || 'third',
study: result.study
},
0,
@ -177,6 +177,7 @@ class userController extends baseController {
try {
user = await userInst.findByEmail(email);
// 新建用户信息
if (!user || !user._id) {
passsalt = yapi.commons.randStr();
data = {
@ -195,12 +196,15 @@ class userController extends baseController {
to: email,
contents: `<h3>亲爱的用户:</h3><p>您好感谢使用YApi平台你的邮箱账号是${email}</p>`
});
} else if(user.type === 'site') {
throw new Error('用户邮箱已被注册')
}
this.setLoginCookie(user._id, user.passsalt);
return true;
} catch (e) {
console.error('third_login:', e.message); // eslint-disable-line
throw new Error(`third_login: ${e.message}`)
return false;
}
}
@ -257,7 +261,7 @@ class userController extends baseController {
}
}
async handlePrivateGroup(uid, username, email) {
async handlePrivateGroup(uid) {
var groupInst = yapi.getInst(groupModel);
await groupInst.save({
uid: uid,