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

Commit

Permalink
fix: refreshed cookie should re sign to update header
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed Feb 21, 2021
1 parent 262e82b commit fc185f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions campusphere/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ exports.signApp = class signApp extends campusphereApp {
}

async signWithForm() {
console.log(this)
if (!this.curTask) {
this.result = { 失败原因: 'Cookie无效,取消签到' }
return
Expand Down
4 changes: 3 additions & 1 deletion serverless/cea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ async function signIn(usersWithTask) {
async function handler(event) {
// load config from toml or env only when we testing
if (!(event.Type === 'Timer')) {
cea.init()
// When testing, we need to get the lastest info
cea.clear()
await cea.init()
}
// Log in and save cookie to cea, using cea.get('cookie') to get them (this function resolve with an users array)
const usersWithTask = await cea.handleCookie()
Expand Down
2 changes: 2 additions & 0 deletions src/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ async function handleLogin(i, storeCookiePath) {
const isNeedLogIn = await sign.signInfo(cookie)
if (isNeedLogIn) {
cookie = await login(conf.get('school'), i)
console.log(cookie)
if (cookie) {
conf.set(storeCookiePath, cookie)
await sign.signInfo(cookie)
log.success(`用户${name}: 已成功刷新并缓存 Cookie`)
}
} else {
Expand Down

0 comments on commit fc185f0

Please sign in to comment.