From dd18a5f5e2a9d72d077ff7f47aec27bb33f16b3a Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 12 Jul 2020 15:00:39 +0200 Subject: [PATCH] WIP: Uniqe-Users --- src/main/java/de/juplo/boot/data/jdbc/UserController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/de/juplo/boot/data/jdbc/UserController.java b/src/main/java/de/juplo/boot/data/jdbc/UserController.java index cec7b6e..0a27a51 100644 --- a/src/main/java/de/juplo/boot/data/jdbc/UserController.java +++ b/src/main/java/de/juplo/boot/data/jdbc/UserController.java @@ -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() -- 2.20.1