@@ -6,6 +6,7 @@ import co.nilin.opex.otp.app.data.OTPResult
66import co.nilin.opex.otp.app.data.VerifyOTPRequest
77import co.nilin.opex.otp.app.model.OTPType
88import co.nilin.opex.otp.app.service.OTPService
9+ import org.springframework.beans.factory.annotation.Value
910import org.springframework.http.HttpStatus
1011import org.springframework.http.ResponseEntity
1112import org.springframework.web.bind.annotation.PostMapping
@@ -15,10 +16,13 @@ import org.springframework.web.bind.annotation.RestController
1516
1617@RestController
1718@RequestMapping(" /v1/otp" )
18- class OTPController (private val otpService : OTPService ) {
19+ class OTPController (
20+ private val otpService : OTPService ,
21+ @Value(" \$ {otp.response-enabled}" ) private val otpCodeResponseEnabled : Boolean ,
22+ ) {
1923
2024 // TODO IMPORTANT: remove in production
21- data class TempOtpResponse (val otp : String )
25+ data class TempOtpResponse (val otp : String? )
2226 // TODO IMPORTANT: remove in production
2327
2428 // TODO IMPORTANT: remove in production
@@ -34,7 +38,8 @@ class OTPController(private val otpService: OTPService) {
3438 )
3539 else
3640 otpService.requestCompositeOTP(request.receivers.toSet(), request.userId, request.action)
37- return ResponseEntity .status(HttpStatus .CREATED ).body(TempOtpResponse (code))
41+ val tempOtpResponse = if (otpCodeResponseEnabled) code else null
42+ return ResponseEntity .status(HttpStatus .CREATED ).body(TempOtpResponse (tempOtpResponse))
3843 }
3944
4045 @PostMapping(" /verify" )
0 commit comments