Skip to content

Commit

Permalink
fix :: missing commit of Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jombidev committed Jun 27, 2024
1 parent a4a765b commit 9b10ba8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
implementation("org.springframework.ai:spring-ai-azure-openai-spring-boot-starter")
implementation("com.azure.spring:spring-cloud-azure-starter-storage-blob")
implementation("com.azure.spring:spring-cloud-azure-starter-storage")
implementation("io.github.robothy:sdwebui-java-sdk:1.2")
implementation("org.springframework.boot:spring-boot-starter-validation")

runtimeOnly("org.mariadb:r2dbc-mariadb:1.1.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.teamapi.palette.dto.user.PasswordUpdateRequest
import com.teamapi.palette.response.Response
import com.teamapi.palette.service.AuthService
import com.teamapi.palette.service.SessionHolder
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.*
import org.springframework.web.server.WebSession
import reactor.core.publisher.Mono
Expand All @@ -17,12 +18,12 @@ class AuthController(
private val sessionHolder: SessionHolder
) {
@PostMapping("/register")
fun register(@RequestBody request: Mono<RegisterRequest>) = request
fun register(@RequestBody @Valid request: Mono<RegisterRequest>) = request
.flatMap { authService.register(it) }
.thenReturn(Response.ok("회원가입 성공"))

@PostMapping("/login")
fun login(@RequestBody request: Mono<LoginRequest>) = request
fun login(@RequestBody @Valid request: Mono<LoginRequest>) = request
.flatMap { authService.login(it) }
.thenReturn(Response.ok("로그인 성공"))

Expand All @@ -35,7 +36,7 @@ class AuthController(
fun updateCurrentSession() = Mono.just(Response.ok("세션 갱신 성공"))

@PatchMapping("/password")
fun passwordUpdate(@RequestBody request: PasswordUpdateRequest) = authService
fun passwordUpdate(@RequestBody @Valid request: PasswordUpdateRequest) = authService
.passwordUpdate(request)
.thenReturn(Response.ok("비밀번호 변경 성공. 다시 로그인 해 주세요."))

Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/teamapi/palette/service/AuthService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AuthService(
return authManager.authenticate(
UsernamePasswordAuthenticationToken(request.email, request.password)
)
.switchIfEmpty(Mono.error(CustomException(ErrorCode.INVALID_CREDENTIALS)))
.flatMap { auth ->
sessionHolder.getSecurityContext().map { it.apply { authentication = auth } }
} // context
Expand Down

0 comments on commit 9b10ba8

Please sign in to comment.