-
Notifications
You must be signed in to change notification settings - Fork 0
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
[YS-68] feat: 연구자 회원가입 API 구현 #19
Merged
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
593ca56
feat: implements participant signup
chock-cho 399fcbb
test: add test codes for SignupMapper and ParticipantSignupUseCase
chock-cho 44e0b73
fix: resolve duplicate requested authentication
chock-cho 699fa1f
refact: move DB Transaction to seperate responsibility to satisfy clean
chock-cho 6741665
refact: Applay automatic Component Scan for UseCase classes
chock-cho dcf3ac6
style: rename API endpoint signup to meet the convention rule
chock-cho af04963
refact: update annotations to validate DateTime Format
chock-cho 81375b2
refact: rename mapper function to match its usecase
chock-cho 9bee38c
fix: reflect updated codes to test code
chock-cho 2af113f
feat: merge from dev branch
chock-cho e84a874
feat: implement researcher member signup
chock-cho 66f6e27
test: update test codes for adjust additional logic
chock-cho 6b8e640
test: add test codes for AuthenticationUtils
chock-cho 83f3275
test: add test codes to UseCases and Service related to signup logic
chock-cho 7016272
feat: add verification entity
chock-cho 813436f
feat: implement Email Send Code and Verification using SMTP
chock-cho fe7229f
fix: add exception codes for Email Verification logic
chock-cho 672a2e9
docs: add application-yml file to .gitignore
chock-cho 7b2fd25
fix: resolve merge conflicts with dev branch
chock-cho faa6ca0
fix: resolve merge conflicts with dev branch
chock-cho e4659db
chore: move packages structure
chock-cho b88a38b
fix: adjust test codes for non-failed test configuration
chock-cho ab97b8c
test: add test codes for Email send verification logic
chock-cho 6e9a2b8
feat: add email verification condition to researcherSignup
chock-cho ad9310c
fix: add test codes for SignupServiceTest to meet the code coverage
chock-cho 9e7d3c6
refact: reflect updation from the code review
chock-cho 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
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
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 굳 좋습니다! 나중에 이메일 템플릿 생성 로직 같은 기능이 추가될 가능성을 고려한다면, 조금 더 SRP 원칙에 따라 세분화하는 방향도 생각해볼 수 있을 것 같아요. 하지만 이는 지금 당장 고민하기보다는 확장 필요성이 생겼을 때 고려해도 충분할 것 같아요. 👍 |
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,40 @@ | ||
package com.dobby.backend.util | ||
|
||
import com.dobby.backend.domain.exception.EmailFormatInvalidException | ||
import java.util.* | ||
import javax.naming.directory.Attributes | ||
import javax.naming.directory.InitialDirContext | ||
|
||
object EmailUtils{ | ||
private fun extractDomain(email:String): String { | ||
if(!email.contains("@")) throw EmailFormatInvalidException() | ||
return email.substringAfter("@") | ||
} | ||
fun isDomainExists(email: String): Boolean { | ||
val domain = extractDomain(email) | ||
return try { | ||
val env = Hashtable<String, String>() | ||
env["java.naming.factory.initial"] = "com.sun.jndi.dns.DnsContextFactory" | ||
val ctx = InitialDirContext(env) | ||
val attributes: Attributes = ctx.getAttributes(domain, arrayOf("MX")) | ||
val mxRecords = attributes["MX"] | ||
mxRecords != null | ||
} catch (ex: Exception) { | ||
false | ||
} | ||
} | ||
|
||
fun isUnivMail(email: String): Boolean { | ||
val eduDomains = setOf( | ||
"postech.edu", | ||
"kaist.edu", | ||
"handong.edu", | ||
"ewhain.net" | ||
) | ||
return email.endsWith("@ac.kr") || eduDomains.any { email.endsWith(it) } | ||
} | ||
fun generateCode(): String { | ||
val randomNum = (0..999999).random() | ||
return String.format("%06d", randomNum) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ class EmailCodeSendUseCaseTest : BehaviorSpec({ | |
val result = emailCodeSendUseCase.execute(request) | ||
|
||
then("정상적으로 EmailSendResponse를 반환해야 한다") { | ||
result.isSucceess shouldBe true | ||
result.isSuccess shouldBe true | ||
} | ||
|
||
then("save 메서드가 호출되어야 한다") { | ||
|
@@ -61,12 +61,10 @@ class EmailCodeSendUseCaseTest : BehaviorSpec({ | |
val request = EmailSendRequest(univEmail = "[email protected]") | ||
|
||
`when`("코드 전송 요청을 하면") { | ||
val exception = shouldThrow<EmailNotUnivException> { | ||
emailCodeSendUseCase.execute(request) | ||
} | ||
|
||
then("EmailNotUnivException 예외가 발생해야 한다") { | ||
exception.message shouldBe "Email domain not found as university email" | ||
val exception = shouldThrow<EmailNotUnivException> { | ||
emailCodeSendUseCase.execute(request) | ||
} | ||
} | ||
} | ||
} | ||
|
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.
여러 가지를 고려할 부분이 많아서 구현하기 힘들었을텐데 고생 많으셨습니다!
코드 잘 작성되었는데, 한 유즈케이스 안에 로직이 집중되다 보니 코드가 길어진 것 같습니다. 해당 유즈케이스에서 사용되는 private method는 EmailUtils와 같은 별도의 유틸리티 클래스로 분리해서 사용하는 것도 좋을 것 같습니다. 이를 통해 코드의 재사용성과 가독성이 향상될 것 같아요!