Skip to content

Commit

Permalink
Add user withdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
yuneg11 committed Dec 11, 2019
1 parent ff98e89 commit 174129f
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 7 deletions.
22 changes: 22 additions & 0 deletions src/backend/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ module.exports.userOpenprofile = async (event) => {
}
};

module.exports.userWithdrawWarning = async (event) => {
if (await checkAuth(event) != null) {
const response = await userHandler.withdrawWarning(event);
console.log(response);
return response;
} else {
console.log("Auth fail");
return getAuthFailResponse();
}
};

module.exports.userWithdraw = async (event) => {
if (await checkAuth(event) != null) {
const response = await userHandler.withdraw(event);
console.log(response);
return response;
} else {
console.log("Auth fail");
return getAuthFailResponse();
}
};

module.exports.itemRegistration = async (event) => {
if (event.source === "serverless-plugin-warmup") {
console.log("WarmUP");
Expand Down
1 change: 0 additions & 1 deletion src/backend/handlers/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ const deleteWarning = async (event) => {
return responseTemplate.itemDeleteWarning(itemId, item_image);
};

// Todo
const deleteOk = async (event) => {
const extras = parser.getExtras(event);
const itemId = extras["itemId"];
Expand Down
25 changes: 24 additions & 1 deletion src/backend/handlers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,32 @@ const openprofile = async (event) => {
}
};

const withdrawWarning = async (event) => {
return responseTemplate.userWithdrawWarning();
};

const withdraw = async (event) => {
const userId = parser.getUserId(event);
const extras = parser.getExtras(event);
const action = extras["action"];

if (action == "ok") {
const result = await database.deleteUser(userId);
if (result.success == true) {
return responseTemplate.userWithdrawOk();
} else {
return responseTemplate.processFail("회원 탈퇴 실패", "회원 탈퇴에 실패하였습니다.");
}
} else {
return responseTemplate.userWithdrawCancel();
}
};

module.exports = {
registration,
authentication,
information,
openprofile
openprofile,
withdrawWarning,
withdraw
};
5 changes: 4 additions & 1 deletion src/backend/responses/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ module.exports = {
itemDeleteWarning: itemResponse.itemDeleteWarning,
itemDeleteOk: itemResponse.itemDeleteOk,
itemDeleteCancel: itemResponse.itemDeleteCancel,
userOpenprofileSuccess: userResponse.userOpenprofileSuccess
userOpenprofileSuccess: userResponse.userOpenprofileSuccess,
userWithdrawWarning: userResponse.userWithdrawWarning,
userWithdrawOk: userResponse.userWithdrawOk,
userWithdrawCancel: userResponse.userWithdrawCancel
};
20 changes: 19 additions & 1 deletion src/backend/responses/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports.userInformation = (nickname, school_name, school_mail, openprofil
const infoOpenProfileList = builder.getListItem(openprofile, "오픈프로필 주소");
const infoReliabilityScoreList = builder.getListItem(reliability_score, "신뢰도");
const infoOpenProfileButton = builder.getButton("오픈프로필", "webLink", openprofile);
const infoWithdrawButton = builder.getButton("회원 탈퇴", "block", "회원 탈퇴", resource.userWithdrawBlockId);
const infoWithdrawButton = builder.getButton("회원 탈퇴", "block", "회원 탈퇴", resource.userWithdrawWarningBlockId);
const infoCard = builder.getListCard(infoTitle, "", [infoNicknameList, infoSchoolNameList, infoSchoolMailList, infoOpenProfileList, infoReliabilityScoreList],
[infoOpenProfileButton, infoWithdrawButton]);

Expand All @@ -69,3 +69,21 @@ module.exports.userOpenprofileSuccess = (openprofile) => {
const listCard = builder.getListCard("오픈프로필 등록 성공", "", [listItem]);
return builder.buildResponse([listCard]);
};

module.exports.userWithdrawWarning = () => {
const okButton = builder.getButton("확인", "block", "확인", resource.userWithdrawBlockId, {action: "ok"});
const cancelButton = builder.getButton("취소", "block", "취소", resource.userWithdrawBlockId, {action: "cancel"});
const basicCard = builder.getBasicCard("정말 회원을 탈퇴하시겠습니까?", "", "", [okButton, cancelButton]);
return builder.buildResponse([basicCard], false);
};

module.exports.userWithdrawOk = () => {
const resultThumbnail = builder.getThumbnail(resource.itemRegistrationSuccessThumbnailUrl);
const basicCard = builder.getBasicCard("회원에서 탈퇴했습니다.", "", resultThumbnail);
return builder.buildResponse([basicCard]);
};

module.exports.userWithdrawCancel = () => {
const textCard = builder.getSimpleText("회원 탈퇴를 취소했습니다.");
return builder.buildResponse([textCard]);
};
12 changes: 12 additions & 0 deletions src/backend/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ functions:
- http:
path: user/openprofile
method: post
userWithdrawWarning:
handler: handler.userWithdrawWarning
events:
- http:
path: user/withdraw/warning
method: post
userWithdraw:
handler: handler.userWithdraw
events:
- http:
path: user/withdraw
method: post
test:
handler: handler.test
events:
Expand Down
5 changes: 2 additions & 3 deletions src/backend/utils/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ module.exports = {
itemDetailBlockId: "5decfa26ffa74800014b098e",
itemDeleteWarningBlockId: "5df085bdffa74800014b1f92",
itemDeleteBlockId: "5df0a89292690d0001fc015b",
itemBuyBlockId: "5decfa26ffa74800014b098e", // Temp
itemReportBlockId: "5decfa26ffa74800014b098e", // Temp
userWithdrawBlockId: "5de3d56d8192ac0001d65d18", // Temp
itemSellerContractVerifyBlockId: "5de3d56d8192ac0001d65d18", // Temp
userWithdrawWarningBlockId: "5df0be478192ac00017876ac",
userWithdrawBlockId: "5df0be598192ac00017876ae",
};

0 comments on commit 174129f

Please sign in to comment.