Closed WongSinYan closed 10 months ago
Added condition
public ResponseEntity<User> register(User newUser) {
if (!isValidPassword(newUser.getUserPassword())) {
return ResponseEntity.badRequest().build();
}
Optional<User> existingUser = user_repository.findById(newUser.getUserId());
if (existingUser.isPresent()) {
return ResponseEntity.status(HttpStatus.CONFLICT).build();
}
User user = user_repository.saveAndFlush(newUser);
return ResponseEntity.status(HttpStatus.CREATED).body(user);
}
Solved and tested, Closing
Summary
Repeated user registration - Duplicated userId
Severity
Critical
Reporter
@wsy617
Assignee
@NY1105
Product
e-commerce
Component
User
Version
Release 2
Environment
Visual Studio Code
Thunder Client (Equivalent to Postman)
Description
Discovery:
Current result:
Status: 201 Created
Expected result:
Status: 409 Conflict