You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by su...@apache.org on 2020/02/22 07:12:32 UTC
[ofbiz-framework] branch trunk updated: Fixed:
UserLoginPasswordHistory is not maintaining password as present in
UserLogin. (OFBIZ-10802) Thanks Rohit Koushal for the patch. Thanks Jacques
Le Roux and Gil Portenseigne for the review.
This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 24fb560 Fixed: UserLoginPasswordHistory is not maintaining password as present in UserLogin. (OFBIZ-10802) Thanks Rohit Koushal for the patch. Thanks Jacques Le Roux and Gil Portenseigne for the review.
new 31ff921 Merge branch 'trunk' of https://gitbox.apache.org/repos/asf/ofbiz-framework into trunk
24fb560 is described below
commit 24fb560ecf4d4180f966421fca6213514fe36698
Author: Suraj Khurana <su...@hotwax.co>
AuthorDate: Sat Feb 22 12:41:36 2020 +0530
Fixed: UserLoginPasswordHistory is not maintaining password as present in UserLogin.
(OFBIZ-10802)
Thanks Rohit Koushal for the patch. Thanks Jacques Le Roux and Gil Portenseigne for the review.
---
applications/party/minilang/user/UserEvents.xml | 4 +---
.../java/org/apache/ofbiz/common/login/LoginServices.java | 12 +++++++-----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/applications/party/minilang/user/UserEvents.xml b/applications/party/minilang/user/UserEvents.xml
index 1dd839f..4afc8d2 100644
--- a/applications/party/minilang/user/UserEvents.xml
+++ b/applications/party/minilang/user/UserEvents.xml
@@ -337,9 +337,7 @@ under the License.
</call-class-method>
<if-compare-field field="autoPasswordChangeEnabled" operator="equals" to-field="true">
<call-class-method method-name="createUserLoginPasswordHistory" class-name="org.apache.ofbiz.common.login.LoginServices">
- <field field="delegator" type="org.apache.ofbiz.entity.Delegator"/>
- <string value="${newUserLogin.userLoginId}"/>
- <string value="${newUserLogin.currentPassword}"/>
+ <field field="newUserLogin" type="org.apache.ofbiz.entity.GenericValue"/>
</call-class-method>
</if-compare-field>
</if-not-empty>
diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java
index d7a1427..19bd37b 100644
--- a/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java
+++ b/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java
@@ -568,8 +568,11 @@ public class LoginServices {
return null;
}
- public static void createUserLoginPasswordHistory(Delegator delegator,String userLoginId, String currentPassword) throws GenericEntityException{
+ public static void createUserLoginPasswordHistory(GenericValue userLogin) throws GenericEntityException{
int passwordChangeHistoryLimit = 0;
+ Delegator delegator = userLogin.getDelegator();
+ String userLoginId = userLogin.getString("userLoginId");
+ String currentPassword = userLogin.getString("currentPassword");
try {
passwordChangeHistoryLimit = EntityUtilProperties.getPropertyAsInteger("security", "password.change.history.limit", 0);
} catch (NumberFormatException nfe) {
@@ -606,8 +609,7 @@ public class LoginServices {
// save this password in history
GenericValue userLoginPwdHistToCreate = delegator.makeValue("UserLoginPasswordHistory", UtilMisc.toMap("userLoginId", userLoginId,"fromDate", nowTimestamp));
- boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));
- userLoginPwdHistToCreate.set("currentPassword", useEncryption ? HashCrypt.cryptUTF8(getHashType(), null, currentPassword) : currentPassword);
+ userLoginPwdHistToCreate.set("currentPassword", currentPassword);
userLoginPwdHistToCreate.create();
}
@@ -702,7 +704,7 @@ public class LoginServices {
try {
userLoginToCreate.create();
- createUserLoginPasswordHistory(delegator,userLoginId, currentPassword);
+ createUserLoginPasswordHistory(userLoginToCreate);
} catch (GenericEntityException e) {
Debug.logWarning(e, "", module);
Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
@@ -849,7 +851,7 @@ public class LoginServices {
try {
userLoginToUpdate.store();
- createUserLoginPasswordHistory(delegator,userLoginId, newPassword);
+ createUserLoginPasswordHistory(userLoginToUpdate);
} catch (GenericEntityException e) {
Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
errMsg = UtilProperties.getMessage(resource,"loginservices.could_not_change_password_write_failure", messageMap, locale);