You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2020/02/05 10:28:58 UTC

[ofbiz-framework] branch release18.12 updated (31c2d72 -> 91cdc81)

This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a change to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git.


    from 31c2d72  Improvement: German translation improvements in HumanResUiLabels (OFBIZ-11134)
     new 218d5a0  Fixed: impersonateLogin (OFBIZ-5409)
     new 91cdc81  Fixed: setUserTimeZone should ran only once based on error (OFBIZ-11329)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 framework/common/groovyScripts/SetTimeZoneFromBrowser.groovy     | 5 +++--
 .../src/main/java/org/apache/ofbiz/common/CommonEvents.java      | 6 ++++--
 themes/common-theme/webapp/common/js/util/setUserTimeZone.js     | 9 ++++-----
 3 files changed, 11 insertions(+), 9 deletions(-)


[ofbiz-framework] 01/02: Fixed: impersonateLogin (OFBIZ-5409)

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 218d5a07a27492b155331bca8f95eedcc470cbfe
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Tue Feb 4 15:35:40 2020 +0100

    Fixed: impersonateLogin
    (OFBIZ-5409)
    
    I reopended this old issue because, while working on  OFBIZ-11329, I found that
    userLogin and impersonateLogin should be removed from
    jsonResponseFromRequestAttributes
    
    Thanks: James Yong for pointing that out
---
 .../common/src/main/java/org/apache/ofbiz/common/CommonEvents.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java b/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java
index a31301d..d6b104c 100644
--- a/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java
+++ b/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java
@@ -63,7 +63,7 @@ public class CommonEvents {
 
     public static final String module = CommonEvents.class.getName();
 
-    private static final String[] ignoreAttrs = new String[] { // Attributes removed for security reason; _ERROR_MESSAGE_ is kept
+    private static final String[] ignoreAttrs = new String[] { // Attributes removed for security reason; _ERROR_MESSAGE_ and _ERROR_MESSAGE_LIST are kept
         "javax.servlet.request.key_size",
         "_CONTEXT_ROOT_",
         "_FORWARDED_FROM_SERVLET_",
@@ -75,7 +75,9 @@ public class CommonEvents {
         "_SERVER_ROOT_URL_",
         "_CONTROL_PATH_",
         "thisRequestUri",
-        "org.apache.tomcat.util.net.secure_protocol_version"
+        "org.apache.tomcat.util.net.secure_protocol_version",
+        "userLogin",
+        "impersonateLogin"
     };
 
     /** Simple event to set the users per-session locale setting. The user's locale


[ofbiz-framework] 02/02: Fixed: setUserTimeZone should ran only once based on error (OFBIZ-11329)

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 91cdc817e1c6b4d45b4b9fcbc4bb1ecc28f0de23
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Wed Feb 5 09:30:55 2020 +0100

    Fixed: setUserTimeZone should ran only once based on error
    (OFBIZ-11329)
    
    This will be notably useful when committing CSRF solution as explained in
    OFBIZ-11306:
    
    SetTimeZoneFromBrowser when starting gives a  RequestHandlerException:
    Invalid or missing CSRF token for AJAX call to path '/SetTimeZoneFromBrowser'.
    Also not only when starting.
    
    Thanks: James Yong for review
---
 framework/common/groovyScripts/SetTimeZoneFromBrowser.groovy | 5 +++--
 themes/common-theme/webapp/common/js/util/setUserTimeZone.js | 9 ++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/framework/common/groovyScripts/SetTimeZoneFromBrowser.groovy b/framework/common/groovyScripts/SetTimeZoneFromBrowser.groovy
index 9a0201a..21f9607 100644
--- a/framework/common/groovyScripts/SetTimeZoneFromBrowser.groovy
+++ b/framework/common/groovyScripts/SetTimeZoneFromBrowser.groovy
@@ -20,13 +20,14 @@
 import org.apache.ofbiz.service.ServiceUtil
 
 public Map SetTimeZoneFromBrowser() {
-    Map results = ServiceUtil.returnSuccess()
     userLogin = from("UserLogin").where("userLoginId", parameters.userLogin.userLoginId).queryFirst();
     if (userLogin) {
         if (!userLogin.lastTimeZone || "null".equals(userLogin.lastTimeZone)) {
             userLogin.lastTimeZone = parameters.localeName
             userLogin.store()
+            return ServiceUtil.returnSuccess()
         }
+    } else {
+        return ServiceUtil.returnError()
     }
-    return results
 }
diff --git a/themes/common-theme/webapp/common/js/util/setUserTimeZone.js b/themes/common-theme/webapp/common/js/util/setUserTimeZone.js
index 4c29928..b74504b 100644
--- a/themes/common-theme/webapp/common/js/util/setUserTimeZone.js
+++ b/themes/common-theme/webapp/common/js/util/setUserTimeZone.js
@@ -17,18 +17,17 @@ specific language governing permissions and limitations
 under the License.
 */
 
-// Only once by session
+// Only once by session (ref https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)
 if (sessionStorage.getItem("SetTimeZoneFromBrowser") === null || sessionStorage.getItem("SetTimeZoneFromBrowser") !== "done") {
-    sessionStorage.setItem("SetTimeZoneFromBrowser", "done");
     var timezone = moment.tz.guess();
     $.ajax({
         url: "SetTimeZoneFromBrowser",
         type: "POST",
         async: false,
         data: "localeName=" + timezone,
-        error: function(error) {
-            if (error != "") {
-                console.error("Error while setting user locale: ", error);
+        success: function(success) {
+            if (success._ERROR_MESSAGE_ === undefined && success._ERROR_MESSAGE_LIST_ === undefined) {
+                sessionStorage.setItem("SetTimeZoneFromBrowser", "done");
             }
         }
     });