From 8738e5cf6eba3e10facdbe1fa97b6905b8d2d756 Mon Sep 17 00:00:00 2001 From: UNIDY2002 Date: Sun, 3 Sep 2023 14:53:18 +0800 Subject: [PATCH] fix(cab): bug in handling accNo --- __tests__/auth.ts | 2 ++ release | 4 +--- src/lib/library.ts | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/__tests__/auth.ts b/__tests__/auth.ts index 213c9cc..2cd2b41 100644 --- a/__tests__/auth.ts +++ b/__tests__/auth.ts @@ -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); diff --git a/release b/release index 3558aa1..6152f99 100644 --- a/release +++ b/release @@ -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 diff --git a/src/lib/library.ts b/src/lib/library.ts index 3e2b8f8..5fd59e0 100644 --- a/src/lib/library.ts +++ b/src/lib/library.ts @@ -414,10 +414,11 @@ export const cabLogin = async (helper: InfoHelper): Promise => { 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 => {