diff --git a/framework/common/config/PrefErrorUiLabels.xml b/framework/common/config/PrefErrorUiLabels.xml
index 1408e3d747..0107595df8 100644
--- a/framework/common/config/PrefErrorUiLabels.xml
+++ b/framework/common/config/PrefErrorUiLabels.xml
@@ -36,6 +36,9 @@
Impossible d'obtenir les préférences de l'utilisateur : argument(s) non valides
ไม่สามารถเรียกค่าสิทธิพิเศษของผู้ใช้:ข้อพิสูจน์ใช้ไม่ได้
+
+ Permissions error while getting user preferences
+
Benutzereinstellungen konnte nicht geholt werden, Lesefehler: {0}
Could not get user preferences (read failure): {0}
diff --git a/framework/common/servicedef/services.xml b/framework/common/servicedef/services.xml
index cac1a5ce43..da3b0bca10 100644
--- a/framework/common/servicedef/services.xml
+++ b/framework/common/servicedef/services.xml
@@ -432,7 +432,6 @@ under the License.
Gets a single user preference.
-
@@ -443,7 +442,6 @@ under the License.
Gets a group of user preferences.
-
diff --git a/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java b/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
index 8319d424d4..8ed99179c6 100644
--- a/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
+++ b/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
@@ -62,8 +62,11 @@ public class PreferenceServices {
* @return Map with the result of the service, the output parameters.
*/
public static Map getUserPreference(DispatchContext ctx, Map context) {
- GenericDelegator delegator = ctx.getDelegator();
Locale locale = (Locale) context.get("locale");
+ if (!PreferenceWorker.isValidGetId(ctx, context)) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.permissionError", locale));
+ }
+ GenericDelegator delegator = ctx.getDelegator();
String userPrefTypeId = (String) context.get("userPrefTypeId");
if (UtilValidate.isEmpty(userPrefTypeId)) {
@@ -112,9 +115,12 @@ public class PreferenceServices {
* @return Map with the result of the service, the output parameters.
*/
public static Map getUserPreferenceGroup(DispatchContext ctx, Map context) {
+ Locale locale = (Locale) context.get("locale");
+ if (!PreferenceWorker.isValidGetId(ctx, context)) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.permissionError", locale));
+ }
GenericDelegator delegator = ctx.getDelegator();
LocalDispatcher dispatcher = ctx.getDispatcher();
- Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
String userPrefGroupId = (String) context.get("userPrefGroupId");
diff --git a/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java b/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java
index c453d1e463..3bb6cb0484 100644
--- a/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java
+++ b/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java
@@ -27,13 +27,11 @@ import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.ObjectType;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.security.Security;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
-
/**
* User preference worker methods.
*/
@@ -44,11 +42,10 @@ public class PreferenceWorker {
*/
public static final String ADMIN_PERMISSION = "USERPREF_ADMIN";
- /**
- * Default userLoginId. Currently set to "DEFAULT_USER_PREFS". This userLoginId is used to
- * retrieve preferences when the user is not logged in.
+ /** Default userLoginId. Currently set to "_NA_". This userLoginId is used to
+ * retrieve default preferences when the user is not logged in.
*/
- public static final String DEFAULT_UID = "DEFAULT_USER_PREFS";
+ public static final String DEFAULT_UID = "_NA_";
/**
* Add a UserPreference GenericValue to a Map.