Skip to content

Commit

Permalink
refactor: 학적 확인시 인증 정보는 헤더에
Browse files Browse the repository at this point in the history
  • Loading branch information
potados99 committed Sep 13, 2022
1 parent 39a7341 commit 0a730a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@

## 업데이트 로그

### 2022.9.13 v2.3.17
- 상태 페이지 개선.
- 재학 상태 확인시 인증 정보는 헤더에 평문으로.

### 2022.9.9 v2.3.16
- 학생 인증 기능 복귀.
- 백엔드 의존성 업데이트.
Expand Down
1 change: 0 additions & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export default {

inuApi: {
accountStatusUrl: `https://api.inuappcenter.kr/account/status`,
key: getSecret('LOGIN_KEY', '앱센터는 모다?'),
},

uicoop: {
Expand Down
14 changes: 4 additions & 10 deletions lib/external/inu/StudentAccountValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import fetch from 'isomorphic-fetch';
import config from '../../../config';
import assert from 'assert';
import {logger} from '@inu-cafeteria/backend-core';
import {encrypt} from '../../common/utils/cipher';
import {withTimeout} from '../../common/utils/timeout';
import {
BadFormedCredentials,
Expand All @@ -34,17 +33,16 @@ export default class StudentAccountValidator {
constructor(private readonly studentId: string, private readonly password: string) {}

async shouldBeUndergraduateWithCorrectCredentials(): Promise<void> {
if (this.studentId === '202099999' && this.password === 'xptmxmzzzz') {
if (this.studentId === '202099999' && this.password === 'xptmxmzzzz' /*테스틐ㅋㅋㅋ*/) {
logger.info('테스트 계정입니다!');
return;
}

const studentId = this.studentId;
const password = this.encryptPassword();

const url = config.external.inuApi.accountStatusUrl;
const headers = {
authorization: `Basic ${Buffer.from(`${studentId}:${password}`).toString('base64')}`,
authorization: `Basic ${Buffer.from(`${this.studentId}:${this.password}`).toString(
'base64'
)}`,
};

const response = await this.getResponse(url, headers);
Expand Down Expand Up @@ -76,8 +74,4 @@ export default class StudentAccountValidator {
throw StudentLoginUnavailable();
}
}

private encryptPassword() {
return encrypt(this.password, config.external.inuApi.key);
}
}

0 comments on commit 0a730a1

Please sign in to comment.