-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#520 ban 여부에 따른 서비스 이용 제한 #530
Merged
The head ref may contain hidden characters: "#520-ban-\uC5EC\uBD80\uC5D0-\uB530\uB978-\uC11C\uBE44\uC2A4-\uC774\uC6A9-\uC81C\uD55C"
Merged
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b679c03
Add: create/join feature restriction
TaehyeonPark 5f4a9b9
Add: BanSchema
TaehyeonPark 89cc169
Add: Swagger docs
TaehyeonPark 2c280c8
Refactor: unnecessary code deletion
TaehyeonPark 1f52f5c
Add: ban user by sso id
TaehyeonPark 6bb6fe0
Merge branch 'dev' into #520-ban-여부에-따른-서비스-이용-제한
TaehyeonPark f6c49ae
Add: pull origin dev
TaehyeonPark c381eff
Merge branch 'dev' of https://github.com/sparcs-kaist/taxi-back into …
TaehyeonPark a8c35ef
Merge branch '#520-ban-여부에-따른-서비스-이용-제한' of https://github.com/sparcs…
TaehyeonPark 56bd968
Add: modulize validation of service ban
TaehyeonPark 7eceae0
Add: resolve comments
TaehyeonPark eecc5f6
Add: resolve comments
TaehyeonPark ab69625
Add: resolve comments
TaehyeonPark b341a33
Add: ban middleware
TaehyeonPark 074d357
Add: resolve comments
TaehyeonPark 8da0c4a
Add: resolve comments
TaehyeonPark 0729f66
Remove: unnecessary require
kmc7468 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const logger = require("./logger"); | ||
const { banModel } = require("./stores/mongo"); | ||
|
||
const getMaxValidServiceBanRecord = async (req) => { | ||
try { | ||
// 현재 시각이 expireAt 보다 작고, 본인인 경우(ban의 userId가 userId랑 같은 경우) 중 serviceName이 "service"인 record를 모두 가져옴 | ||
const bans = await banModel.find({ | ||
userSid: req.session.loginInfo.sid, | ||
expireAt: { | ||
$gte: req.timestamp, | ||
}, | ||
serviceName: "service", | ||
}); | ||
if (bans.length > 0) { | ||
// 가장 expireAt이 큰 정지 기록만 반환함. | ||
const latestBan = bans.reduce( | ||
(max, ban) => (ban.expireAt > max.expireAt ? ban : max), | ||
bans[0] | ||
); | ||
return latestBan; | ||
} | ||
return; | ||
} catch (err) { | ||
logger.error( | ||
"Error occured while getValidServiceBanRecord: " + err.message | ||
); | ||
return; | ||
} | ||
}; | ||
|
||
module.exports = { | ||
getMaxValidServiceBanRecord, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
큰 차이는 없을 것 같은데 저는 이럴 때 gte보다는 gt를 사용하는걸 선호하긴 합니다! (expireAt이 이때부터 차단 해제된다는 의미니까요) 이건 그냥 optional로 원하시면 수정해주셔도 될 것 같습니다.