diff --git a/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala b/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala index fa21830e2..0d9334ff5 100644 --- a/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala +++ b/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala @@ -589,23 +589,14 @@ import net.liftweb.util.Helpers._ */ override def sendPasswordReset(name: String) { findAuthUserByUsernameLocallyLegacy(name).toList ::: findUsersByEmailLocally(name) map { - // reason of case parameter name is "u" instead of "user": trait AuthUser have constant mumber name is "user" - // So if the follow case paramter name is "user" will cause compile warnings case u if u.validated_? => u.resetUniqueId().save - //NOTE: here, if server_mode = portal, so we need modify the resetLink to portal_hostname, then developer can get proper response.. val resetPasswordLinkProps = Constant.HostName val resetPasswordLink = APIUtil.getPropsValue("portal_hostname", resetPasswordLinkProps)+ passwordResetPath.mkString("/", "/", "/")+urlEncode(u.getUniqueId()) - // Use Apache Commons Email wrapper instead of Lift Mailer - val emailBodies = generateResetEmailBodies(u, resetPasswordLink) - - // Extract text and HTML content from email bodies - val textContent = emailBodies.find(_.isInstanceOf[net.liftweb.util.Mailer.PlainMailBodyType]) - .map(_.asInstanceOf[net.liftweb.util.Mailer.PlainMailBodyType].toString.replace("PlainMailBodyType(", "").replace(")", "")) - val htmlContent = emailBodies.find(_.isInstanceOf[net.liftweb.util.Mailer.XHTMLMailBodyType]) - .map(_.asInstanceOf[net.liftweb.util.Mailer.XHTMLMailBodyType].toString.replace("XHTMLMailBodyType(", "").replace(")", "")) - + // Directly generate content using JakartaMail/CommonsEmailWrapper + val textContent = Some(s"Please use the following link to reset your password: $resetPasswordLink") + val htmlContent = Some(s"
Please use the following link to reset your password:
") val emailContent = EmailContent( from = emailFrom, to = List(u.getEmail), @@ -627,8 +618,6 @@ import net.liftweb.util.Helpers._ case u => sendValidationEmail(u) } - // In order to prevent any leakage of information we use the same message for all cases - // Note: Individual success/error messages are now handled in the email sending logic above } override def lostPasswordXhtml = { @@ -660,22 +649,10 @@ import net.liftweb.util.Helpers._ * Overridden to use the hostname set in the props file */ override def sendValidationEmail(user: TheUserType) { - val resetLink = Constant.HostName+"/"+validateUserPath.mkString("/")+ - "/"+urlEncode(user.getUniqueId()) - + val resetLink = Constant.HostName+"/"+validateUserPath.mkString("/")+"/"+urlEncode(user.getUniqueId()) val email: String = user.getEmail - - val msgXml = signupMailBody(user, resetLink) - - // Use Apache Commons Email wrapper instead of Lift Mailer - val emailBodies: List[Mailer.MailBodyType] = generateValidationEmailBodies(user, resetLink) - - // Extract text and HTML content from email bodies - val textContent = emailBodies.find(_.isInstanceOf[net.liftweb.util.Mailer.PlainMailBodyType]) - .map(_.asInstanceOf[net.liftweb.util.Mailer.PlainMailBodyType].toString.replace("PlainMailBodyType(", "").replace(")", "")) - val htmlContent = emailBodies.find(_.isInstanceOf[net.liftweb.util.Mailer.XHTMLMailBodyType]) - .map(_.asInstanceOf[net.liftweb.util.Mailer.XHTMLMailBodyType].toString.replace("XHTMLMailBodyType(", "").replace(")", "")) - + val textContent = Some(s"Welcome! Please validate your account by clicking the following link: $resetLink") + val htmlContent = Some(s"Welcome! Please validate your account by clicking the following link:
") val emailContent = EmailContent( from = emailFrom, to = List(user.getEmail), @@ -684,7 +661,6 @@ import net.liftweb.util.Helpers._ textContent = textContent, htmlContent = htmlContent ) - sendHtmlEmail(emailContent) match { case Full(messageId) => logger.debug(s"Validation email sent successfully with Message-ID: $messageId")