diff --git a/config.ts b/config.ts index 0cad492..6dc90a4 100644 --- a/config.ts +++ b/config.ts @@ -142,8 +142,7 @@ export default { }, inuApi: { - accountStatusUrl: (studentId: string, password: string) => - `https://api.inuappcenter.kr/account/status?studentId=${studentId}&password=${password}`, + accountStatusUrl: `https://api.inuappcenter.kr/account/status`, key: getSecret('LOGIN_KEY', '앱센터는 모다?'), }, diff --git a/lib/external/inu/StudentAccountValidator.ts b/lib/external/inu/StudentAccountValidator.ts index 0b433b9..1716028 100644 --- a/lib/external/inu/StudentAccountValidator.ts +++ b/lib/external/inu/StudentAccountValidator.ts @@ -41,9 +41,13 @@ export default class StudentAccountValidator { const studentId = this.studentId; const password = this.encryptPassword(); - const url = config.external.inuApi.accountStatusUrl(studentId, password); - const response = await this.getResponse(url); + const url = config.external.inuApi.accountStatusUrl; + const headers = { + authorization: `Basic ${Buffer.from(`${studentId}:${password}`).toString('base64')}`, + }; + + const response = await this.getResponse(url, headers); switch (response.status) { case 200: @@ -59,9 +63,9 @@ export default class StudentAccountValidator { } } - private async getResponse(url: string) { + private async getResponse(url: string, headers: Record) { try { - return await withTimeout(() => fetch(url), 3000, StudentLoginUnavailable); + return await withTimeout(() => fetch(url, {headers}), 3000, StudentLoginUnavailable); } catch (e) { // 응답조차 받지 못하고 예외가 발생한다? 뭔가 잘못된 일이 생긴 것이니, // 적절한 예외(StudentLoginUnavailable)로 치환하여 줍니다.