This repository has been archived by the owner on Jun 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const { handleCookie, conf } = require('../index') | ||
const { signApp } = require('../campusphere/app') | ||
|
||
// Grab users array | ||
const users = conf.get('users') | ||
// Grab school info | ||
const school = conf.get('school') | ||
|
||
;(async () => { | ||
// Log in and save cookie to conf, using conf.get('cookie') to get them | ||
await handleCookie() | ||
// wait * minute for signing | ||
await sleep(0) | ||
// Sign in | ||
await signIn() | ||
})() | ||
|
||
async function sleep(timeout) { | ||
return new Promise(r => setTimeout(r, timeout * 1000 * 60)) | ||
} | ||
|
||
async function signIn() { | ||
// sign in asynchronizedly with promise all and diff instance of signApp class | ||
await Promise.all( | ||
users.map(async i => { | ||
const cookie = i.cookie | ||
? { campusphere: i.cookie } | ||
: conf.get(`cookie.${i.alias || i.username}`) | ||
|
||
const sign = new signApp(school, i) | ||
|
||
await sign.signInfo(cookie) | ||
await sign.signWithForm() | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters