Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
fix: circular refs, v2.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed Mar 21, 2021
1 parent 63b85de commit 78716eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 0 additions & 2 deletions TEST/dcampus.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ async function signIn(usersWithTask) {
usersWithTask.map(async i => {
await i.sign.signWithForm()
logs[i.alias || i.id] = i.sign.result
// Fix circular object
delete i.sign
})
)
cea.close()
Expand Down
15 changes: 10 additions & 5 deletions campusphere/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ exports.signApp = class signApp extends campusphereApp {
connection: 'keep-alive',
}
this.addr = school.addr
this.user = user
this.id = user.username
// temporary store user info to reuse it, fix circular ref
process.env[user.username] = user
}

async signInfo(cookie) {
const user = process.env[this.id]
if (!cookie) {
console.log(`用户${this.user.alias}:无效的 Cookie,尝试重新登录`)
console.log(`用户${user.alias}:无效的 Cookie,尝试重新登录`)
return true
}
this.headers.cookie = cookie.campusphere
Expand Down Expand Up @@ -77,7 +80,7 @@ exports.signApp = class signApp extends campusphereApp {
} = signDetails.datas

const placeList = signPlaceSelected
const isSignAtHome = this.user.addr
const isSignAtHome = process.env[this.id].addr
;[longitude, latitude] = isSignAtHome ? this.signAtHomePos() : this.locale(placeList[0])

const extraFieldItems = this.fillExtra(extraField)
Expand Down Expand Up @@ -119,9 +122,11 @@ exports.signApp = class signApp extends campusphereApp {
}

signAtHomePos() {
const user = process.env[this.id]

// Hard coded position info
// Randomly generated from http://api.map.baidu.com/lbsapi
const userAddr = this.user.addr
const userAddr = user.addr
const noRandom = userAddr instanceof Array
const posGenFromCitys = noRandom
? [userAddr]
Expand Down Expand Up @@ -175,7 +180,7 @@ exports.signApp = class signApp extends campusphereApp {
model: 'Cock',
appVersion: '8.2.14',
systemVersion: '4.4.4',
userId: this.user.username,
userId: process.env[this.id].username,
systemName: 'android',
lat: form.latitude.toString(),
deviceId: v1(),
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": "@beetcb/cea",
"version": "2.1.3",
"version": "2.1.4",
"description": "campusphere-elegant-auth: login to swms/campusphere at ease",
"main": "dist/index.js",
"bin": "dist/cli.js",
Expand Down

0 comments on commit 78716eb

Please sign in to comment.