Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
修复邮箱登录状态码错误,增加相关提示 #633
Browse files Browse the repository at this point in the history
  • Loading branch information
Binaryify committed Nov 7, 2019
1 parent f254aa2 commit abf7bc4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 更新日志
### 3.25.1 | 2019.11.07
- 修复邮箱登录状态码错误,增加相关提示 [#633](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/633)

### 3.25.0 | 2019.11.06
- 新增 `云村热评` 接口[#626](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/626)

Expand Down
18 changes: 17 additions & 1 deletion module/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@

const crypto = require('crypto')

module.exports = (query, request) => {
module.exports = async (query, request) => {
query.cookie.os = 'pc'
const data = {
username: query.email,
password: crypto.createHash('md5').update(query.password).digest('hex'),
rememberLogin: 'true'
}
const result = await request(
'POST', `https://music.163.com/weapi/login`, data,
{crypto: 'weapi', ua: 'pc', cookie: query.cookie, proxy: query.proxy}
)
if(result.body.code === 502){
return new Promise(resolve => {
resolve({
status: 200,
body: {
'msg': '账号或密码错误',
'code': 502,
'message': '账号或密码错误'
}
})
})
}
return request(
'POST', `https://music.163.com/weapi/login`, data,
{crypto: 'weapi', ua: 'pc', cookie: query.cookie, proxy: query.proxy}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NeteaseCloudMusicApi",
"version": "3.25.0",
"version": "3.25.1",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",
Expand Down
4 changes: 3 additions & 1 deletion util/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ const createRequest = (method, url, data, options) => {

answer.body = JSON.parse(body)
answer.status = answer.body.code || res.statusCode

if(answer.body.code === 502){
answer.status = 200
}
}

} catch (e) {
Expand Down

0 comments on commit abf7bc4

Please sign in to comment.