Skip to content

Commit 4ed8fd3

Browse files
committed
feat: 完善课程各网站 Check 机制
1 parent 75070b3 commit 4ed8fd3

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

auth/cas.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export default class CASAuth {
263263
}
264264

265265
async loginHUBM() {
266-
const url = 'http://hub.m.hust.edu.cn/hub_weix';
266+
const url = 'https://hub.m.hust.edu.cn/hub_weix';
267267
const isLogin = await this.checkLoginStatus();
268268

269269
if (!isLogin) {
@@ -328,6 +328,7 @@ export default class CASAuth {
328328
return false;
329329
}
330330
}
331+
331332
async loginPhysics() {
332333
const url = 'http://empxk.hust.edu.cn/';
333334
const isLogin = await this.checkLoginStatus();
@@ -369,6 +370,28 @@ export default class CASAuth {
369370
}
370371
}
371372

373+
async checkHUBM() {
374+
const url = 'http://hub.m.hust.edu.cn/hub_weix/';
375+
376+
try {
377+
const response = await this.axios.get(url);
378+
return !isNeedAuth(response);
379+
} catch (e) {
380+
return false;
381+
}
382+
}
383+
384+
async checkMHUB() {
385+
const url = 'https://mhub.hust.edu.cn/';
386+
387+
try {
388+
const response = await this.axios.get(url);
389+
return !isNeedAuth(response);
390+
} catch (e) {
391+
return false;
392+
}
393+
}
394+
372395
async checkONE() {
373396
const url = 'https://one.hust.edu.cn/dcp/';
374397

index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ export default class HUST {
189189
switch (client) {
190190
case Client.news:
191191
return await this.auth.checkONE();
192+
case Client.course:
193+
return (await Promise.all([
194+
this.auth.checkPhysics(),
195+
this.auth.checkHUBM(),
196+
this.auth.checkMHUB(),
197+
this.auth.checkHUBS(),
198+
])).every((item) => item);
192199
default:
193200
throw new Error(`Client ${client} not supported`);
194201
}

0 commit comments

Comments
 (0)