From 506824a8b78e43db0bbacabb219bddef9fdf89ce Mon Sep 17 00:00:00 2001 From: Denis Natusch Date: Sun, 19 Nov 2023 13:08:30 +0100 Subject: [PATCH] Logout user if changing their own username Closes #45 --- src/main/java/catering/users/UserController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/catering/users/UserController.java b/src/main/java/catering/users/UserController.java index eab74cc..c9cee89 100644 --- a/src/main/java/catering/users/UserController.java +++ b/src/main/java/catering/users/UserController.java @@ -74,13 +74,13 @@ public class UserController { userManagement.setPassword(password, user.getUserAccount()); } - userManagement.save(user); - - if (!username.isBlank()){ + if (username != userAccount.getUsername()){ + userManagement.save(user); return "redirect:/logout"; + } else { + userManagement.save(user); + return "redirect:/profile"; } - - return "redirect:/profile"; } @GetMapping("/profile/disable")