update code security otp
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.billpaymentservice.bbps.controller;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.auth.AuthResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.AuthResponses;
|
||||
import com.billpaymentservice.bbps.dto.auth.LoginRequest;
|
||||
import com.billpaymentservice.bbps.dto.auth.OtpSendResponse;
|
||||
import com.billpaymentservice.bbps.dto.auth.RegisterRequest;
|
||||
import com.billpaymentservice.bbps.dto.auth.VerifyOtpRequest;
|
||||
import com.billpaymentservice.bbps.service.AuthService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Slf4j
|
||||
public class AuthController {
|
||||
|
||||
private final AuthService authService;
|
||||
|
||||
public AuthController(AuthService authService) {
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/sendOtp", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<OtpSendResponse> sendOtp(@Validated @RequestBody LoginRequest request) {
|
||||
log.info("Received sendOtp request for mobile: {}", request.getMobile());
|
||||
OtpSendResponse resp = authService.sendOtp(request);
|
||||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/verifyOtp", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<AuthResponses> verifyOtp(@Validated @RequestBody VerifyOtpRequest request) {
|
||||
AuthResponses resp = authService.verifyOtp(request);
|
||||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/register", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<AuthResponse> register(@Validated @RequestBody RegisterRequest request) {
|
||||
AuthResponse resp = authService.registerUser(request);
|
||||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
@PostMapping("/loginWithoutDecryption")
|
||||
public ResponseEntity<AuthResponses> login(@RequestBody LoginRequest loginRequest) {
|
||||
try {
|
||||
AuthResponses authResponse = authService.authenticateUser(loginRequest);
|
||||
return ResponseEntity.ok(authResponse);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(500).body(AuthResponses.builder().status("Unauthorized")
|
||||
.message("An unexpected error occurred").statusCode(500).build());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import com.billpaymentservice.bbps.dto.request.LoginRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.AuthResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.AuthResponses;
|
||||
import com.billpaymentservice.bbps.service.MasterDataService;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
@@ -148,14 +148,4 @@ public class MasterDataController {
|
||||
return ResponseEntity.ok(masterDataService.fetchPlanByCategories(requestModel));
|
||||
}
|
||||
|
||||
@PostMapping("/loginWithoutDecryption")
|
||||
public ResponseEntity<AuthResponse> login(@RequestBody LoginRequest loginRequest) {
|
||||
try {
|
||||
AuthResponse authResponse = masterDataService.authenticateUser(loginRequest);
|
||||
return ResponseEntity.ok(authResponse);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(500).body(AuthResponse.builder().status("Unauthorized")
|
||||
.message("An unexpected error occurred").statusCode(500).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,11 +54,13 @@ public class PaymentController {
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value="/callback/paymentIntiate", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> handleBillValidateCallback(@RequestBody TransactionStatusResponse transactionStatusResponse) {
|
||||
ResponseModel genralResp=paymentService.handlePaymentIntiateCallback(transactionStatusResponse);
|
||||
// Return a response indicating successful receipt
|
||||
return ResponseEntity.ok(genralResp);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user