nodebb-plugin-freelog
Advanced tools
Comparing version 0.0.21 to 0.0.22
100
index.js
@@ -46,2 +46,5 @@ const plugin = {}; | ||
} | ||
if (!password) { | ||
return next(new Error('[[error:invalid-password]]')); | ||
} | ||
async.waterfall([ | ||
@@ -58,12 +61,12 @@ // 登录freelog | ||
function(data, callback) { | ||
if (data.status !== 200 || data.data.errCode !== 0) { | ||
console.log('登录失败'); | ||
if (data.status !== 200) { | ||
callback(new Error('登录接口调用失败')); | ||
} else if (data.data.errCode !== 0) { | ||
callback(new Error('[[error:invalid-username]]')); | ||
return; | ||
} else { | ||
callback(null, data.data.data); | ||
} | ||
callback(null, data.data.data); | ||
}, | ||
// 根据登录信息获取nodeBB用户信息 | ||
function(userInfo, callback) { | ||
console.log('登录成功,用户信息:', userInfo, userInfo.userId); | ||
User.getUserData(userInfo.userId).then(userData => { | ||
@@ -73,21 +76,20 @@ callback(null, userData, userInfo); | ||
}, | ||
// 判定nodeBB用户是否已同步,如果没同步,则同步 | ||
function(nodeUserInfo, freelogUserInfo, callback) { | ||
console.log({ nodeUserInfo, freelogUserInfo }); | ||
if (!nodeUserInfo || !nodeUserInfo.uid) { | ||
console.log('同步用户数据到nodeBB'); | ||
User.create({ | ||
uid: freelogUserInfo.userId, | ||
username: freelogUserInfo.username, | ||
password: password, | ||
fullname: freelogUserInfo.username, | ||
picture: freelogUserInfo.headImage, | ||
email: freelogUserInfo.email | ||
}).then(() => { | ||
User.getUserData(freelogUserInfo.userId).then(userData => { | ||
callback(null, userData, userInfo); | ||
}).catch(error => callback(error)); | ||
}); | ||
} else { | ||
if (nodeUserInfo && nodeUserInfo.uid > 0) { | ||
callback(null, nodeUserInfo); | ||
return; | ||
} | ||
User.create({ | ||
uid: freelogUserInfo.userId, | ||
username: freelogUserInfo.username, | ||
password: password, | ||
fullname: freelogUserInfo.username, | ||
picture: freelogUserInfo.headImage, | ||
email: freelogUserInfo.email | ||
}).then(() => { | ||
User.getUserData(freelogUserInfo.userId).then(userData => { | ||
callback(null, userData); | ||
}).catch(error => callback(error)); | ||
}); | ||
} | ||
@@ -101,60 +103,4 @@ ], function(error, result) { | ||
}); | ||
// console.log(username, password); | ||
// console.log('登录成功'); | ||
// console.log('secret', nconf.get('secret')); | ||
// var user = { | ||
// 'uid': 50017, | ||
// 'username': 'yuliang', | ||
// 'userslug': 'yuliang', | ||
// 'email': '4896819@qq.com', | ||
// 'email:confirmed': 0, | ||
// 'joindate': 1659511461079, | ||
// 'lastonline': 1659511461079, | ||
// 'picture': 'https://image.freelog.com/headImage/50017', | ||
// 'icon:bgColor': '#2196f3', | ||
// 'fullname': null, | ||
// 'location': null, | ||
// 'birthday': null, | ||
// 'website': null, | ||
// 'aboutme': null, | ||
// 'signature': null, | ||
// 'uploadedpicture': null, | ||
// 'profileviews': 0, | ||
// 'reputation': 0, | ||
// 'postcount': 0, | ||
// 'topiccount': 0, | ||
// 'lastposttime': 0, | ||
// 'banned': false, | ||
// 'banned:expire': 0, | ||
// 'status': 'online', | ||
// 'flags': null, | ||
// 'followerCount': 0, | ||
// 'followingCount': 0, | ||
// 'cover:url': null, | ||
// 'cover:position': null, | ||
// 'groupTitle': null, | ||
// 'mutedUntil': 0, | ||
// 'mutedReason': null, | ||
// 'displayname': 'yuliang', | ||
// 'groupTitleArray': [], | ||
// 'icon:text': 'Y', | ||
// 'joindateISO': '2022-08-03T07:24:21.079Z', | ||
// 'lastonlineISO': '2022-08-03T07:24:21.079Z', | ||
// 'banned_until': 0, | ||
// 'banned_until_readable': 'Not Banned' | ||
// }; | ||
// | ||
// next(null, user, '[[success:authentication-successful]]'); | ||
// | ||
// console.log(User.getUserData); | ||
// | ||
// // console.log(userData); | ||
// userController.getUserDataByField(1, 'username', username, function(userData) { | ||
// console.log(userData); | ||
// next(null, userData, '[[success:authentication-successful]]'); | ||
// }); | ||
}; | ||
module.exports = plugin; |
@@ -5,3 +5,3 @@ { | ||
"description": "NodeBB Forum", | ||
"version": "0.0.21", | ||
"version": "0.0.22", | ||
"homepage": "http://www.nodebb.org", | ||
@@ -8,0 +8,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5188
116