Skip to content

Commit

Permalink
Merge pull request #180 from sparcs-kaist/#178-bug-login-for-graduates
Browse files Browse the repository at this point in the history
#178 Bug: 졸업생 로그인 불가
  • Loading branch information
withSang authored Nov 10, 2022
2 parents e3ca489 + b8b94ac commit 6bc851f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/db/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
},
user: {
nickname: RegExp("^[A-Za-z가-힣ㄱ-ㅎㅏ-ㅣ0-9-_ ]{3,25}$"),
allowedEmployeeTypes: RegExp("^([PEUR]|[SA]|[PEUR][SA])$"),
profileImgType: RegExp("^(image/png|image/jpg|image/jpeg)$"),
},
chat: {
Expand Down
7 changes: 5 additions & 2 deletions src/service/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ const {
generateProfileImageUrl,
getFullUsername,
} = require("../modules/modifyProfile");
const { user: userPattern } = require("../db/patterns");

// SPARCS SSO
const Client = require("../auth/sparcsso");
const client = new Client(security.sparcssso?.id, security.sparcssso?.key);

const transUserData = (userData) => {
const kaistInfo = userData.kaist_info ? JSON.parse(userData.kaist_info) : {};
const allowedEmployeeTypes = ["P", "S", "ES"]; // P: 교수, S: 학생, ES: 교직원인 학생

// info.ku_std_no: 학번
// info.isEligible: 카이스트 구성원인지 여부. DB에 저장하지 않음.
const info = {
id: userData.uid,
sid: userData.sid,
Expand All @@ -23,7 +26,7 @@ const transUserData = (userData) => {
kaist: kaistInfo?.ku_std_no || "",
sparcs: userData.sparcs_id || "",
email: userData.email,
isEligible: allowedEmployeeTypes.includes(kaistInfo?.employeeType), // 카이스트 구성원인지 여부. DB에 저장하지 않음.
isEligible: userPattern.allowedEmployeeTypes.test(kaistInfo?.employeeType),
};
return info;
};
Expand Down

0 comments on commit 6bc851f

Please sign in to comment.