Author: jleroux
Date: Sat Mar 31 20:35:42 2012
New Revision: 1307895

URL: http://svn.apache.org/viewvc?rev=1307895&view=rev
Log:
A patch from BREMA Dev Team "email password broken" 
https://issues.apache.org/jira/browse/OFBIZ-3790

There is no productStoreId in the session for an user of a backend application, 
and ProductStoreEmailSetting is not available. This is the reason.
However we can use default template and default sender's address from 
general.properties in this case.
Also removes some dead code.

jleroux: this uses  "general.properties", "defaultFromEmailAddress". So to work 
correctly it still needs "defaultFromEmailAddress" (default 
[email protected]), "mail.smtp.relay.host" (default =localhost) and such 
to be set correctly... In other words the message "A new password has been 
created and sent to you. Please check your Email." could even more misleading 
if people are not aware about setting SMTP

Modified:
    
ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/login/LoginEvents.java
    ofbiz/trunk/framework/common/config/SecurityextUiLabels.xml

Modified: 
ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/login/LoginEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/login/LoginEvents.java?rev=1307895&r1=1307894&r2=1307895&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/login/LoginEvents.java
 (original)
+++ 
ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/login/LoginEvents.java
 Sat Mar 31 20:35:42 2012
@@ -181,13 +181,9 @@ public class LoginEvents {
 
         String errMsg = null;
 
-        Map<String, String> subjectData = FastMap.newInstance();
-        subjectData.put("productStoreId", productStoreId);
-
         boolean useEncryption = 
"true".equals(UtilProperties.getPropertyValue("security.properties", 
"password.encrypt"));
 
         String userLoginId = request.getParameter("USERNAME");
-        subjectData.put("userLoginId", userLoginId);
 
         if ((userLoginId != null) && 
("true".equals(UtilProperties.getPropertyValue("security.properties", 
"username.lowercase")))) {
             userLoginId = userLoginId.toLowerCase();
@@ -229,13 +225,6 @@ public class LoginEvents {
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
-        if (supposedUserLogin == null) {
-            // the Username was not found
-            Map<String, String> messageMap = UtilMisc.toMap("userLoginId", 
userLoginId);
-            errMsg = UtilProperties.getMessage(resource, 
"loginevents.user_with_the_username_not_found", messageMap, 
UtilHttp.getLocale(request));
-            request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            return "error";
-        }
 
         StringBuilder emails = new StringBuilder();
         GenericValue party = null;
@@ -269,13 +258,10 @@ public class LoginEvents {
             Debug.logError(e, "Problem getting ProductStoreEmailSetting", 
module);
         }
 
-        if (productStoreEmail == null) {
-            errMsg = UtilProperties.getMessage(resource, 
"loginevents.problems_with_configuration_contact_customer_service", 
UtilHttp.getLocale(request));
-            request.setAttribute("_ERROR_MESSAGE_", errMsg);
-            return "error";
+        String bodyScreenLocation = null;
+        if (productStoreEmail != null) {
+            bodyScreenLocation = 
productStoreEmail.getString("bodyScreenLocation");
         }
-
-        String bodyScreenLocation = 
productStoreEmail.getString("bodyScreenLocation");
         if (UtilValidate.isEmpty(bodyScreenLocation)) {
             bodyScreenLocation = defaultScreenLocation;
         }
@@ -291,11 +277,16 @@ public class LoginEvents {
         Map<String, Object> serviceContext = FastMap.newInstance();
         serviceContext.put("bodyScreenUri", bodyScreenLocation);
         serviceContext.put("bodyParameters", bodyParameters);
-        serviceContext.put("subject", productStoreEmail.getString("subject"));
-        serviceContext.put("sendFrom", productStoreEmail.get("fromAddress"));
-        serviceContext.put("sendCc", productStoreEmail.get("ccAddress"));
-        serviceContext.put("sendBcc", productStoreEmail.get("bccAddress"));
-        serviceContext.put("contentType", 
productStoreEmail.get("contentType"));
+        if (productStoreEmail != null) {
+            serviceContext.put("subject", 
productStoreEmail.getString("subject"));
+            serviceContext.put("sendFrom", 
productStoreEmail.get("fromAddress"));
+            serviceContext.put("sendCc", productStoreEmail.get("ccAddress"));
+            serviceContext.put("sendBcc", productStoreEmail.get("bccAddress"));
+            serviceContext.put("contentType", 
productStoreEmail.get("contentType"));
+        } else {
+            serviceContext.put("subject", UtilProperties.getMessage(resource, 
"loginservices.password_reminder_subject", UtilMisc.toMap("userLoginId", 
userLoginId), UtilHttp.getLocale(request)));
+            serviceContext.put("sendFrom", 
UtilProperties.getPropertyValue("general.properties", 
"defaultFromEmailAddress"));
+        }
         serviceContext.put("sendTo", emails.toString());
         serviceContext.put("partyId", party.getString("partyId"));
 

Modified: ofbiz/trunk/framework/common/config/SecurityextUiLabels.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/SecurityextUiLabels.xml?rev=1307895&r1=1307894&r2=1307895&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/config/SecurityextUiLabels.xml (original)
+++ ofbiz/trunk/framework/common/config/SecurityextUiLabels.xml Sat Mar 31 
20:35:42 2012
@@ -242,20 +242,6 @@
         <value xml:lang="zh">这个用户已经登录了。</value>
         <value xml:lang="zh_TW">此使用者已經登入。</value>
     </property>
-    <property key="loginevents.user_with_the_username_not_found">
-        <value xml:lang="de">Ein Benutzer mit dem Namen "${userLoginId}" 
konnte nicht gefunden werden. Bitte erneut eingeben.</value>
-        <value xml:lang="en">A user with the Username "${userLoginId}" was not 
found, please re-enter.</value>
-        <value xml:lang="es">El usuario "${userLoginId}" no fue encontrado, 
por favor intente de nuevo.</value>
-        <value xml:lang="fr">Le nom d'utilisateur "${userLoginId}" est 
inconnu, entrez le de nouveau SVP.</value>
-        <value xml:lang="it">L'utente "${userLoginId}" non è stato trovato, 
prego inserirlo di nuovo.</value>
-        <value xml:lang="nl">Er is geen gebruiker gevonden met de 
gebruikersnaam "${userLoginId}", probeer het a.u.b. opnieuw.</value>
-        <value xml:lang="pt_BR">Um usuário com o nome de usuário "$ 
{userLoginId}" não foi encontrado, por favor tente novamente.</value>
-        <value xml:lang="ro">Utilizatorul cu nume "${userLoginId}" nu a fost 
gasit, va rog re-introduceti.</value>
-        <value xml:lang="ru">Пользователь с именем 
"${userLoginId}" не найден, пожалуйста повторите 
ввод.</value>
-        <value 
xml:lang="th">ผู้ใช้ที่ใช้ชื่อผู้เข้าใช้
 "${userLoginId}" ไม่พบ, 
กรุณากรอกข้อมูลใหม่</value>
-        <value xml:lang="zh">没有找到用户名为"${userLoginId}" 
的用户,请重新输入。</value>
-        <value xml:lang="zh_TW">沒有名為 "${userLoginId}" 的使用者, 
請重新輸入。</value>
-    </property>
     <property key="loginevents.username_not_found_reenter">
         <value xml:lang="de">Benutzername konnte nicht gefunden werden. Bitte 
erneut eingeben.</value>
         <value xml:lang="en">The Username was not found, please 
re-enter.</value>
@@ -711,6 +697,10 @@
         <value xml:lang="zh">缺少密码或验证密码。</value>
         <value xml:lang="zh_TW">缺少密碼或驗證密碼。</value>
     </property>
+    <property key="loginservices.password_reminder_subject">
+        <value xml:lang="en">Password Reminder (${userLoginId})".</value>
+        <value xml:lang="fr">Rappel du mot de passe(${userLoginId})".</value>
+    </property>
     <property key="loginservices.since_datetime">
         <value xml:lang="de">(seit ${disabledDateTime})</value>
         <value xml:lang="en">since ${disabledDateTime}.</value>


Reply via email to