WIP: Uniqe-Users
authorKai Moritz <kai@juplo.de>
Sun, 12 Jul 2020 13:00:39 +0000 (15:00 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 12 Jul 2020 13:00:39 +0000 (15:00 +0200)
src/main/java/de/juplo/boot/data/jdbc/UserController.java

index cec7b6e..0a27a51 100644 (file)
@@ -32,7 +32,11 @@ public class UserController {
             @RequestBody String username) {
         String sanitizedUsername = UserController.sanitize(username);
         User user = new User(sanitizedUsername, LocalDateTime.now(), false);
+
+        // Ein Fehler wegen doppeltem username verhindert das Speichern
         repository.save(user);
+        user = repository.findByUsername(sanitizedUsername);
+
         UriComponents uri =
             builder
                 .fromCurrentRequest()