From 87c8bf2f657fd5dce43977eb89533a01aaa90265 Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Thu, 18 Jul 2024 17:29:17 +0200 Subject: [PATCH 1/2] #2905 Fixed 'Go to my default page' after change 'Home page' - Added setHomeUrl() for user when setting home url --- src/com/serotonin/mango/web/dwr/MiscDwr.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/serotonin/mango/web/dwr/MiscDwr.java b/src/com/serotonin/mango/web/dwr/MiscDwr.java index 60324a88c3..f88fa2d1de 100644 --- a/src/com/serotonin/mango/web/dwr/MiscDwr.java +++ b/src/com/serotonin/mango/web/dwr/MiscDwr.java @@ -276,6 +276,7 @@ public void setHomeUrl(String url) { url = url.substring(1); // Save the result + Common.getUser().setHomeUrl(url); new UserDao().saveHomeUrl(Common.getUser().getId(), url); } From ad4d4c48095e83fb14fe800aa6d9b14323ca27a1 Mon Sep 17 00:00:00 2001 From: patrykb0802 Date: Mon, 22 Jul 2024 14:32:39 +0200 Subject: [PATCH 2/2] #2905 Fixed 'Go to my default page' after change 'Home page' - Added permission validation --- src/com/serotonin/mango/web/dwr/MiscDwr.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/serotonin/mango/web/dwr/MiscDwr.java b/src/com/serotonin/mango/web/dwr/MiscDwr.java index f88fa2d1de..31ea7a737b 100644 --- a/src/com/serotonin/mango/web/dwr/MiscDwr.java +++ b/src/com/serotonin/mango/web/dwr/MiscDwr.java @@ -25,7 +25,6 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.ResourceBundle; @@ -253,6 +252,7 @@ public void setLocale(String locale) { public void setHomeUrl(String url) { + Permissions.ensureValidUser(); // Remove the scheme, domain, and context if there. HttpServletRequest request = WebContextFactory.get() .getHttpServletRequest(); @@ -276,7 +276,10 @@ public void setHomeUrl(String url) { url = url.substring(1); // Save the result - Common.getUser().setHomeUrl(url); + User user = Common.getUser(); + user.setHomeUrl(url); + UserService userService = new UserService(); + userService.saveHomeUrl(user.getId(), url); new UserDao().saveHomeUrl(Common.getUser().getId(), url); }