mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-23 13:59:28 +08:00
fix: 修改第三方登陆出现的bug
This commit is contained in:
parent
826c7c69f1
commit
d8571f07c9
@ -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,
|
||||
@ -176,7 +176,8 @@ 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,
|
||||
|
Loading…
Reference in New Issue
Block a user