Skip to content

Commit

Permalink
Fix user creation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sefadegirmenci committed Jul 17, 2022
1 parent a3d8b02 commit f389ba9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/com/eistgeist/flightsystem/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class User {
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private JourneyList journeys; /* The flights that user saved */

public User() {
}

public User(String userName, String password) {
this.userName = userName;
this.password = password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import org.apache.coyote.Response;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -22,7 +23,7 @@ public class UserController {
@Operation(description = "Add a user and its password")
public ResponseEntity<User> addUser(@RequestBody User user) {
if(user == null) return (ResponseEntity<User>) ResponseEntity.badRequest();
return ResponseEntity.ok(userService.addUser(user));
return new ResponseEntity<User>(userService.addUser(user), HttpStatus.CREATED);
}

@GetMapping("")
Expand Down

0 comments on commit f389ba9

Please sign in to comment.