@@ -589,23 +589,14 @@ import net.liftweb.util.Helpers._
589589 */
590590 override def sendPasswordReset (name : String ) {
591591 findAuthUserByUsernameLocallyLegacy(name).toList ::: findUsersByEmailLocally(name) map {
592- // reason of case parameter name is "u" instead of "user": trait AuthUser have constant mumber name is "user"
593- // So if the follow case paramter name is "user" will cause compile warnings
594592 case u if u.validated_? =>
595593 u.resetUniqueId().save
596- // NOTE: here, if server_mode = portal, so we need modify the resetLink to portal_hostname, then developer can get proper response..
597594 val resetPasswordLinkProps = Constant .HostName
598595 val resetPasswordLink = APIUtil .getPropsValue(" portal_hostname" , resetPasswordLinkProps)+
599596 passwordResetPath.mkString(" /" , " /" , " /" )+ urlEncode(u.getUniqueId())
600- // Use Apache Commons Email wrapper instead of Lift Mailer
601- val emailBodies = generateResetEmailBodies(u, resetPasswordLink)
602-
603- // Extract text and HTML content from email bodies
604- val textContent = emailBodies.find(_.isInstanceOf [net.liftweb.util.Mailer .PlainMailBodyType ])
605- .map(_.asInstanceOf [net.liftweb.util.Mailer .PlainMailBodyType ].toString.replace(" PlainMailBodyType(" , " " ).replace(" )" , " " ))
606- val htmlContent = emailBodies.find(_.isInstanceOf [net.liftweb.util.Mailer .XHTMLMailBodyType ])
607- .map(_.asInstanceOf [net.liftweb.util.Mailer .XHTMLMailBodyType ].toString.replace(" XHTMLMailBodyType(" , " " ).replace(" )" , " " ))
608-
597+ // Directly generate content using JakartaMail/CommonsEmailWrapper
598+ val textContent = Some (s " Please use the following link to reset your password: $resetPasswordLink" )
599+ val htmlContent = Some (s " <p>Please use the following link to reset your password:</p><p><a href=' $resetPasswordLink'> $resetPasswordLink</a></p> " )
609600 val emailContent = EmailContent (
610601 from = emailFrom,
611602 to = List (u.getEmail),
@@ -627,8 +618,6 @@ import net.liftweb.util.Helpers._
627618 case u =>
628619 sendValidationEmail(u)
629620 }
630- // In order to prevent any leakage of information we use the same message for all cases
631- // Note: Individual success/error messages are now handled in the email sending logic above
632621 }
633622
634623 override def lostPasswordXhtml = {
@@ -660,22 +649,10 @@ import net.liftweb.util.Helpers._
660649 * Overridden to use the hostname set in the props file
661650 */
662651 override def sendValidationEmail (user : TheUserType ) {
663- val resetLink = Constant .HostName + " /" + validateUserPath.mkString(" /" )+
664- " /" + urlEncode(user.getUniqueId())
665-
652+ val resetLink = Constant .HostName + " /" + validateUserPath.mkString(" /" )+ " /" + urlEncode(user.getUniqueId())
666653 val email : String = user.getEmail
667-
668- val msgXml = signupMailBody(user, resetLink)
669-
670- // Use Apache Commons Email wrapper instead of Lift Mailer
671- val emailBodies : List [Mailer .MailBodyType ] = generateValidationEmailBodies(user, resetLink)
672-
673- // Extract text and HTML content from email bodies
674- val textContent = emailBodies.find(_.isInstanceOf [net.liftweb.util.Mailer .PlainMailBodyType ])
675- .map(_.asInstanceOf [net.liftweb.util.Mailer .PlainMailBodyType ].toString.replace(" PlainMailBodyType(" , " " ).replace(" )" , " " ))
676- val htmlContent = emailBodies.find(_.isInstanceOf [net.liftweb.util.Mailer .XHTMLMailBodyType ])
677- .map(_.asInstanceOf [net.liftweb.util.Mailer .XHTMLMailBodyType ].toString.replace(" XHTMLMailBodyType(" , " " ).replace(" )" , " " ))
678-
654+ val textContent = Some (s " Welcome! Please validate your account by clicking the following link: $resetLink" )
655+ val htmlContent = Some (s " <p>Welcome! Please validate your account by clicking the following link:</p><p><a href=' $resetLink'> $resetLink</a></p> " )
679656 val emailContent = EmailContent (
680657 from = emailFrom,
681658 to = List (user.getEmail),
@@ -684,7 +661,6 @@ import net.liftweb.util.Helpers._
684661 textContent = textContent,
685662 htmlContent = htmlContent
686663 )
687-
688664 sendHtmlEmail(emailContent) match {
689665 case Full (messageId) =>
690666 logger.debug(s " Validation email sent successfully with Message-ID: $messageId" )
0 commit comments