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 commit is contained in:
@@ -435,7 +435,7 @@ public class LoginServices {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void createUserLoginPasswordHistory(Delegator delegator,String userLoginId, String currentPassword) throws GenericEntityException{
|
||||
public static void createUserLoginPasswordHistory(GenericValue userLogin) throws GenericEntityException{
|
||||
int passwordChangeHistoryLimit = 0;
|
||||
try {
|
||||
passwordChangeHistoryLimit = EntityUtilProperties.getPropertyAsInteger("security", "password.change.history.limit", 0).intValue();
|
||||
@@ -473,8 +473,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();
|
||||
}
|
||||
|
||||
@@ -569,7 +568,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());
|
||||
@@ -712,7 +711,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);
|
||||
@@ -943,6 +942,9 @@ public class LoginServices {
|
||||
}
|
||||
|
||||
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).intValue();
|
||||
} catch (NumberFormatException nfe) {
|
||||
|
||||
Reference in New Issue
Block a user