-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from TeamMiso/feat/mail-check
회원가입시 이메일 인증번호 인증 api 구현
- Loading branch information
Showing
9 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/andreas311/miso/domain/auth/exception/EmailKeyInvalidException.kt
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,7 @@ | ||
package andreas311.miso.domain.auth.exception | ||
|
||
import andreas311.miso.global.error.exception.ErrorCode | ||
import andreas311.miso.global.error.exception.MisoException | ||
|
||
class EmailKeyInvalidException : MisoException(ErrorCode.EMAIL_KEY_IS_INVALID) { | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/andreas311/miso/domain/email/presentation/EmailController.kt
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,20 @@ | ||
package andreas311.miso.domain.email.presentation | ||
|
||
import andreas311.miso.domain.email.presentation.data.request.EmailCheckRequestDto | ||
import andreas311.miso.domain.email.service.EmailCheckService | ||
import andreas311.miso.global.annotation.RequestController | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
|
||
@RequestController("/email") | ||
class EmailController( | ||
private val emailCheckService: EmailCheckService | ||
) { | ||
|
||
@PostMapping | ||
fun emailCheck(@RequestBody emailCheckRequestDto: EmailCheckRequestDto): ResponseEntity<Void> = | ||
emailCheckService.execute(emailCheckRequestDto) | ||
.let { ResponseEntity.status(HttpStatus.OK).build() } | ||
} |
5 changes: 5 additions & 0 deletions
5
...ain/kotlin/andreas311/miso/domain/email/presentation/data/request/EmailCheckRequestDto.kt
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,5 @@ | ||
package andreas311.miso.domain.email.presentation.data.request | ||
|
||
data class EmailCheckRequestDto( | ||
val randomKey: String | ||
) |
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
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/andreas311/miso/domain/email/service/EmailCheckService.kt
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,8 @@ | ||
package andreas311.miso.domain.email.service | ||
|
||
import andreas311.miso.domain.email.presentation.data.request.EmailCheckRequestDto | ||
|
||
interface EmailCheckService { | ||
|
||
fun execute(emailCheckRequestDto: EmailCheckRequestDto) | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/andreas311/miso/domain/email/service/impl/EmailCheckServiceImpl.kt
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,21 @@ | ||
package andreas311.miso.domain.email.service.impl | ||
|
||
import andreas311.miso.domain.auth.exception.EmailKeyInvalidException | ||
import andreas311.miso.domain.email.presentation.data.request.EmailCheckRequestDto | ||
import andreas311.miso.domain.email.repository.EmailRepository | ||
import andreas311.miso.domain.email.service.EmailCheckService | ||
import andreas311.miso.global.annotation.RollbackService | ||
|
||
@RollbackService | ||
class EmailCheckServiceImpl( | ||
private val emailRepository: EmailRepository | ||
) : EmailCheckService { | ||
|
||
override fun execute(emailCheckRequestDto: EmailCheckRequestDto) { | ||
|
||
val email = emailRepository.findByRandomKey(emailCheckRequestDto.randomKey) | ||
?: throw EmailKeyInvalidException() | ||
|
||
email.updateAuthentication(true) | ||
} | ||
} |
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