Skip to content

Commit

Permalink
优化刷新登录代码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangtongfa committed Aug 21, 2017
1 parent 74866cb commit ad88393
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 更新日志
### 2.7.0 | 2017.8.21
优化刷新登录代码

### 2.6.5 | 2017.7.16
优化 CORS 设置

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": "2.6.9",
"version": "2.7.0",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",
Expand Down
2 changes: 1 addition & 1 deletion router/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ router.get('/', (req, res) => {
data,
cookie,
(music_req, cookie) => {
console.log(music_req)
// console.log(music_req)
res.set({
'Set-Cookie': cookie
})
Expand Down
17 changes: 8 additions & 9 deletions router/login_refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ const { createWebAPIRequest } = require('../util/util')

router.get('/', (req, res) => {
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
let csrf = req.query.t || ''
for (let i in cookie) {
if (cookie[i].name == '__csrf') {
csrf = cookie.value
}
}
const data = {
csrf_token: csrf
csrf_token: ''
}
console.log({ cookie })
createWebAPIRequest(
'music.163.com',
`/weapi/login/token/refresh?csrf_token=${csrf}`,
`/weapi/login/token/refresh`,
'POST',
data,
cookie,
music_req => {
(music_req, cookie) => {
console.log({ cookie })
res.set({
'Set-Cookie': cookie
})
res.send(music_req)
},
err => res.status(502).send('fetch error')
Expand Down

0 comments on commit ad88393

Please sign in to comment.