Skip to content

Commit

Permalink
fixed login
Browse files Browse the repository at this point in the history
  • Loading branch information
gnehs committed Feb 23, 2022
1 parent 2c6ac5d commit 7c17360
Show file tree
Hide file tree
Showing 3 changed files with 3,344 additions and 19 deletions.
20 changes: 14 additions & 6 deletions dataModule/netease2.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ const imageUrl = x => `/pokaapi/req/?moduleName=Netease2&data=${encodeURICompone
async function login(config) {
let result;
if (config.login.method == 'phone') {
result = await client(options(`/login/cellphone?phone=${config.login.account}&password=${config.login.password}`));
if (config.login.countrycode) {
result = await client(options(`/login/cellphone?phone=${config.login.account}&password=${config.login.password}&countrycode=${config.login.countrycode}`));
} else {
result = await client(options(`/login/cellphone?phone=${config.login.account}&password=${config.login.password}`));
}
} else {
result = await client(options(`/login?email=${config.login.account}&password=${config.login.password}`));
}
Expand All @@ -114,8 +118,12 @@ async function login(config) {
return
}
isLoggedin = result.code == 200;
userId = result.profile.userId
pokaLog.logDM('Netease2', `${result.profile.nickname}(${userId}) 登入${isLoggedin ? "成功" : "失敗"}`)
if (isLoggedin) {
userId = result.profile.userId
pokaLog.logDM('Netease2', `${result.profile.nickname}(${userId}) 登入成功`)
} else if (result.msg) {
pokaLog.logDMErr('Netease2', result.msg)
}
return result;
}
//自動重新登入
Expand All @@ -126,16 +134,16 @@ schedule.scheduleJob("0 0 * * *", async function () {
async function onLoaded() {
if (!config.enabled) return false;
return await fs.ensureFile(pin).then(async () => {
if (config && config.login && config.login.method && config.login.password) {
if (config && config.login && config.login.method && config.login.password && config.login.account) {
let result = await login(config);
if ((await result.code) == 200) {
return true;
} else {
pokaLog.logDM('Netease2', `登入失敗`)
pokaLog.logDMErr('Netease2', `登入失敗`)
return false;
}
} else {
pokaLog.logDM('Netease2', `登入失敗,尚未設定帳號密碼`)
pokaLog.logDMErr('Netease2', `登入失敗,尚未設定帳號密碼`)
return false;
}
});
Expand Down
Loading

0 comments on commit 7c17360

Please sign in to comment.