From 78b8ffba918b465ec2eefa3854054f3825b94c6f Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Thu, 8 Feb 2018 14:52:49 +0100
Subject: [PATCH] OO-3284: don't show error in change password workflow

---
 .../olat/registration/PwChangeController.java | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/olat/registration/PwChangeController.java b/src/main/java/org/olat/registration/PwChangeController.java
index a91bbc2a2b8..28c7220b364 100644
--- a/src/main/java/org/olat/registration/PwChangeController.java
+++ b/src/main/java/org/olat/registration/PwChangeController.java
@@ -216,9 +216,8 @@ public class PwChangeController extends BasicController {
 				sendEmail(ureq, identity);
 			}
 		} else {
-			// no user exists, this is an error in the pwchange page
-			// REVIEW:pb:2009-11-23:gw, setter should not be necessary. -> check the error already in th emailOrUsernameCtr
-			emailOrUsernameCtr.setUserNotIdentifiedError();
+			logWarn("Failed to identify user in password change workflow: " + emailOrUsername, null);
+			stepSendEmailConfiration();
 		}
 	}
 	
@@ -256,7 +255,7 @@ public class PwChangeController extends BasicController {
 
 		String emailAdress = identity.getUser().getProperty(UserConstants.EMAIL, locale); 
 		if (!StringHelper.containsNonWhitespace(emailAdress)) {
-			emailOrUsernameCtr.setUserNotIdentifiedError();
+			stepSendEmailConfiration();//for security reason, don't show an error, go simply to the next step
 			return null;
 		}
 		
@@ -290,16 +289,20 @@ public class PwChangeController extends BasicController {
 		MailerResult result = mailManager.sendExternMessage(bundle, null, false);
 		if(result.getReturnCode() == MailerResult.OK) {
 			getWindowControl().setInfo(translate("email.sent"));
-			// prepare next step
-			wic.setCurStep(2);
-			myContent.contextPut("text", translate("step2.pw.text"));
-			emailOrUsernameCtr.getInitialComponent().setVisible(false);
-		} else {
-			showError("email.notsent");
 		}
+		stepSendEmailConfiration();
 		return tk;
 	}
 	
+	/**
+	 * Activate the step 2
+	 */
+	private void stepSendEmailConfiration() {
+		wic.setCurStep(2);
+		myContent.contextPut("text", translate("step2.pw.text"));
+		emailOrUsernameCtr.getInitialComponent().setVisible(false);
+	}
+	
 	/**
 	 * Look for user in "Person" and "user" tables. Fist search by user name
 	 * and if the user cannot be found, search by email address.
-- 
GitLab