Skip to content
This repository has been archived by the owner on Sep 24, 2023. It is now read-only.

Commit

Permalink
fix(cab): bug in handling accNo
Browse files Browse the repository at this point in the history
  • Loading branch information
UNIDY2002 committed Sep 3, 2023
1 parent 72c2b8a commit 8738e5c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions __tests__/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ it("should login successfully.", async () => {
expect(dayjs(firstDay).day()).toEqual(1);
expect((await helper.getCrTimetable()).length).toBeGreaterThan(0);
expect((await helper.getCampusCardInfo()).balance).toBeGreaterThanOrEqual(0);
await helper.getLibraryRoomBookingInfoList();
expect(helper.getLibraryRoomAccNo() === -1).toBeFalsy();
await helper.logout();
expect(helper.mocked()).toEqual(false);
}, 60000);
4 changes: 1 addition & 3 deletions release
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
internal: introduce a new `RoamingPolicy` (`"cab"`) for cab.lib.tsinghua.edu.cn login to make code-scan happy
feat: add an API to get accNo of cab.lib.tsinghua.edu.cn
fix: type of accNo
fix(cab): bug in handling accNo
3 changes: 2 additions & 1 deletion src/lib/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,11 @@ export const cabLogin = async (helper: InfoHelper): Promise<void> => {
throw new Error("Failed to get payload in cabLogin. Retry later.");
}
await roam(helper, "cab", payload);
const {pid} = await cabFetch(LIBRARY_ROOM_BOOKING_USER_INFO_URL);
const {pid, accNo} = await cabFetch(LIBRARY_ROOM_BOOKING_USER_INFO_URL);
if (pid !== helper.userId) {
throw new Error("Failed to get pid in cabLogin. Retry later.");
}
accountBaseInfo.accNo = accNo;
};

export const getLibraryRoomBookingInfoList = async (helper: InfoHelper): Promise<LibRoomInfo[]> => {
Expand Down

0 comments on commit 8738e5c

Please sign in to comment.