<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>How to disable password change notification in 7/DXP?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=97545180" />
  <subtitle>How to disable password change notification in 7/DXP?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=97545180</id>
  <updated>2026-04-06T07:11:30Z</updated>
  <dc:date>2026-04-06T07:11:30Z</dc:date>
  <entry>
    <title>RE: How to disable password change notification in 7/DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118320605" />
    <author>
      <name>Montej Shah</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118320605</id>
    <updated>2020-01-23T08:56:39Z</updated>
    <published>2020-01-23T08:56:39Z</published>
    <summary type="html">Finally, i got the way to remove the notification only for the update password.I had used service-wrapper to override 2 methods for update passwords. Override with the same code as existing one,  just comment out send notification part.Liferay version 7.1&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;package com.motus.aspire.service.wrapper;import java.util.Date;import org.osgi.service.component.annotations.Component;import com.liferay.mail.kernel.service.MailServiceUtil;&lt;br /&gt;import com.liferay.portal.kernel.exception.ModelListenerException;&lt;br /&gt;import com.liferay.portal.kernel.exception.PortalException;&lt;br /&gt;import com.liferay.portal.kernel.exception.UserPasswordException;&lt;br /&gt;import com.liferay.portal.kernel.log.Log;&lt;br /&gt;import com.liferay.portal.kernel.log.LogFactoryUtil;&lt;br /&gt;import com.liferay.portal.kernel.model.PasswordPolicy;&lt;br /&gt;import com.liferay.portal.kernel.model.User;&lt;br /&gt;import com.liferay.portal.kernel.security.auth.PasswordModificationThreadLocal;&lt;br /&gt;import com.liferay.portal.kernel.security.ldap.LDAPSettingsUtil;&lt;br /&gt;import com.liferay.portal.kernel.security.pwd.PasswordEncryptorUtil;&lt;br /&gt;import com.liferay.portal.kernel.service.PasswordPolicyLocalServiceUtil;&lt;br /&gt;import com.liferay.portal.kernel.service.PasswordTrackerLocalServiceUtil;&lt;br /&gt;import com.liferay.portal.kernel.service.ServiceWrapper;&lt;br /&gt;import com.liferay.portal.kernel.service.UserLocalServiceUtil;&lt;br /&gt;import com.liferay.portal.kernel.service.UserLocalServiceWrapper;&lt;br /&gt;import com.liferay.portal.kernel.util.GetterUtil;&lt;br /&gt;import com.liferay.portal.kernel.util.StringPool;&lt;br /&gt;import com.liferay.portal.kernel.util.Validator;&lt;br /&gt;import com.liferay.portal.security.pwd.PwdToolkitUtil;/**&lt;br /&gt; * @author aspire48&lt;br /&gt; */&lt;br /&gt;@Component(immediate = true, property = {}, service = ServiceWrapper.class)&lt;br /&gt;public class UserServiceOverride extends UserLocalServiceWrapper {  public UserServiceOverride() {&lt;br /&gt;    super(null);&lt;br /&gt;  }  private static final Log log = LogFactoryUtil.getLog(UserServiceOverride.class.getName());  @Override&lt;br /&gt;  public User updatePassword(long userId, String password1, String password2, boolean passwordReset)&lt;br /&gt;      throws PortalException {&lt;br /&gt;    log.info(&amp;#34;Executing updatePassword ====&amp;#34;);&lt;br /&gt;    return updatePassword(userId, password1, password2, passwordReset, true);&lt;br /&gt;  }  @Override&lt;br /&gt;  public User updatePassword(long userId, String password1, String password2, boolean passwordReset,&lt;br /&gt;      boolean silentUpdate) throws PortalException {&lt;br /&gt;    log.info(&amp;#34;Executing updatePassword  method which is overriden&amp;#34;);&lt;br /&gt;    // Password hashing takes a long time. Therefore, encrypt the password&lt;br /&gt;    // before we get the user to avoid&lt;br /&gt;    // an org.hibernate.StaleObjectStateException.    String newEncPwd = PasswordEncryptorUtil.encrypt(password1);    User user = UserLocalServiceUtil.getUser(userId);    if (!silentUpdate) {&lt;br /&gt;      validatePassword(user.getCompanyId(), userId, password1, password2);      trackPassword(user);&lt;br /&gt;    }    if (user.hasCompanyMx()) {&lt;br /&gt;      MailServiceUtil.updatePassword(user.getCompanyId(), userId, password1);&lt;br /&gt;    }    user.setPassword(newEncPwd);&lt;br /&gt;    user.setPasswordUnencrypted(password1);&lt;br /&gt;    user.setPasswordEncrypted(true);&lt;br /&gt;    user.setPasswordReset(passwordReset);    if (!silentUpdate || (user.getPasswordModifiedDate() == null)) {&lt;br /&gt;      user.setPasswordModifiedDate(new Date());&lt;br /&gt;    }    user.setDigest(StringPool.BLANK);&lt;br /&gt;    user.setGraceLoginCount(0);    if (!silentUpdate) {&lt;br /&gt;      user.setPasswordModified(true);&lt;br /&gt;    }    PasswordModificationThreadLocal.setPasswordModified(user.getPasswordModified());&lt;br /&gt;    PasswordModificationThreadLocal.setPasswordUnencrypted(user.getPasswordUnencrypted());    try {&lt;br /&gt;      user = UserLocalServiceUtil.updateUser(user);&lt;br /&gt;    } catch (ModelListenerException mle) {&lt;br /&gt;      Throwable throwable = mle.getCause();      String msg = GetterUtil.getString(throwable.getMessage());      if (LDAPSettingsUtil.isPasswordPolicyEnabled(user.getCompanyId())) {&lt;br /&gt;        String[] errorPasswordHistoryKeywords =&lt;br /&gt;            LDAPSettingsUtil.getErrorPasswordHistoryKeywords(user.getCompanyId());        for (String errorPasswordHistoryKeyword : errorPasswordHistoryKeywords) {          if (msg.contains(errorPasswordHistoryKeyword)) {&lt;br /&gt;            throw new UserPasswordException.MustNotBeRecentlyUsed(userId);&lt;br /&gt;          }&lt;br /&gt;        }&lt;br /&gt;      }      throw new UserPasswordException.MustComplyWithModelListeners(userId, mle);&lt;br /&gt;    }    if (!silentUpdate) {&lt;br /&gt;      user.setPasswordModified(false);&lt;br /&gt;    }&lt;strong&gt;    // Override service to don&amp;#39;t send notification&lt;br /&gt;    // if (!silentUpdate &amp;amp;&amp;amp; (PrincipalThreadLocal.getUserId() != userId)) {&lt;br /&gt;    // sendPasswordNotification(user, user.getCompanyId(), password1, null, null, null, null, null,&lt;br /&gt;    // ServiceContextThreadLocal.getServiceContext());&lt;br /&gt;    // }&lt;/strong&gt;    return user;&lt;br /&gt;  }  protected void validatePassword(long companyId, long userId, String password1, String password2)&lt;br /&gt;      throws PortalException {    if (Validator.isNull(password1) || Validator.isNull(password2)) {&lt;br /&gt;      throw new UserPasswordException.MustNotBeNull(userId);&lt;br /&gt;    }    if (!password1.equals(password2)) {&lt;br /&gt;      throw new UserPasswordException.MustMatch(userId);&lt;br /&gt;    }    PasswordPolicy passwordPolicy =&lt;br /&gt;        PasswordPolicyLocalServiceUtil.getPasswordPolicyByUserId(userId);    PwdToolkitUtil.validate(companyId, userId, password1, password2, passwordPolicy);&lt;br /&gt;  }  protected void trackPassword(User user) throws PortalException {&lt;br /&gt;    String oldEncPwd = user.getPassword();    if (!user.isPasswordEncrypted()) {&lt;br /&gt;      oldEncPwd = PasswordEncryptorUtil.encrypt(user.getPassword());&lt;br /&gt;    }    PasswordTrackerLocalServiceUtil.trackPassword(user.getUserId(), oldEncPwd);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;Dependency need to add for the override the above service&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;            &amp;lt;groupId&amp;gt;com.liferay.portal&amp;lt;/groupId&amp;gt;&lt;br /&gt;            &amp;lt;artifactId&amp;gt;com.liferay.portal.kernel&amp;lt;/artifactId&amp;gt;&lt;br /&gt;            &amp;lt;version&amp;gt;3.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;            &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;&lt;br /&gt;        &amp;lt;/dependency&amp;gt;&lt;br /&gt;        &amp;lt;dependency&amp;gt;&lt;br /&gt;            &amp;lt;groupId&amp;gt;org.osgi&amp;lt;/groupId&amp;gt;&lt;br /&gt;            &amp;lt;artifactId&amp;gt;osgi.cmpn&amp;lt;/artifactId&amp;gt;&lt;br /&gt;            &amp;lt;version&amp;gt;6.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;            &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;&lt;br /&gt;        &amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;            &amp;lt;groupId&amp;gt;com.liferay.portal&amp;lt;/groupId&amp;gt;&lt;br /&gt;            &amp;lt;artifactId&amp;gt;com.liferay.portal.impl&amp;lt;/artifactId&amp;gt;&lt;br /&gt;            &amp;lt;version&amp;gt;3.49.8&amp;lt;/version&amp;gt;&lt;br /&gt;            &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;&lt;br /&gt;        &amp;lt;/dependency&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;Reference:Source code: &lt;a href="https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/service/impl/UserLocalServiceImpl.java"&gt;https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/service/impl/UserLocalServiceImpl.java&lt;/a&gt;</summary>
    <dc:creator>Montej Shah</dc:creator>
    <dc:date>2020-01-23T08:56:39Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to disable password change notification in 7/DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=117453795" />
    <author>
      <name>Jan Tošovský</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=117453795</id>
    <updated>2019-10-14T21:42:50Z</updated>
    <published>2019-10-14T21:42:50Z</published>
    <summary type="html">Hi Fernando, I ended up cloning almost all UserLocalServiceImp stuff, but I am still receiving emails with my changed password. While I can hit breakpoint for sending reset password link, when new password is set and submitted, it really continues without touching my wrapper code.  &lt;br /&gt;What exactly is meant by &amp;#34; So, the only solution I see is to reimplement (just copy, really) all the stuff that updateUser() does, without calling sendPassword().&amp;#34; ?&lt;br /&gt;Does this approach works for you?</summary>
    <dc:creator>Jan Tošovský</dc:creator>
    <dc:date>2019-10-14T21:42:50Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to disable password change notification in 7/DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=97546799" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=97546799</id>
    <updated>2017-10-24T23:15:41Z</updated>
    <published>2017-10-24T23:15:41Z</published>
    <summary type="html">&lt;div class="quote-title"&gt;Fernando Fernandez:&lt;/div&gt;&lt;blockquote&gt;Password is being changed by the OOTB portlets through a call to updateUser(). This can be intercepted in the wrapper, but when the super.updateUser() is calling sendPassword() it will not go through the wrapper again.&lt;br /&gt;&lt;br /&gt;So, the only solution I see is to reimplement (just  copy, really) all the stuff that updateUser() does, without calling sendPassword().&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Yep, that&amp;#39;s pretty much what you&amp;#39;re stuck with, as well as hitting the other methods that may be updating passwords.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2017-10-24T23:15:41Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to disable password change notification in 7/DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=97546781" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=97546781</id>
    <updated>2017-10-24T22:56:11Z</updated>
    <published>2017-10-24T22:56:11Z</published>
    <summary type="html">&lt;div class="quote-title"&gt;David H Nebinger:&lt;/div&gt;&lt;blockquote&gt;The only way you&amp;#39;re going to be able to do that is through a UserLocalService wrapper to override the methods which send the various emails.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Hi David, &lt;br /&gt;&lt;br /&gt;I tried, but it seems a hard way... :-)&lt;br /&gt;&lt;br /&gt;Just intercepting sendPassword() in the UserLocalServiceWrapper doesn&amp;#39;t seem to be enough. &lt;br /&gt;&lt;br /&gt;Password is being changed by the OOTB portlets through a call to updateUser(). This can be intercepted in the wrapper, but when the super.updateUser() is calling sendPassword() it will not go through the wrapper again.&lt;br /&gt;&lt;br /&gt;So, the only solution I see is to reimplement (just  copy, really) all the stuff that updateUser() does, without calling sendPassword().&lt;br /&gt;&lt;br /&gt;It seems ugly, but if there&amp;#39;s no other way, I guess that&amp;#39;s what will have to be done.&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;&lt;br /&gt;Fernando</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2017-10-24T22:56:11Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to disable password change notification in 7/DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=97546528" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=97546528</id>
    <updated>2017-10-24T22:18:23Z</updated>
    <published>2017-10-24T22:18:23Z</published>
    <summary type="html">The only way you&amp;#39;re going to be able to do that is through a UserLocalService wrapper to override the methods which send the various emails.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2017-10-24T22:18:23Z</dc:date>
  </entry>
  <entry>
    <title>How to disable password change notification in 7/DXP?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=97545179" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=97545179</id>
    <updated>2017-10-24T21:26:37Z</updated>
    <published>2017-10-24T21:26:37Z</published>
    <summary type="html">Hi,&lt;br /&gt;&lt;br /&gt;I have a requirement that is to totally disable the password notification email and I can&amp;#39;t find a way of doing this.&lt;br /&gt;&lt;br /&gt;I don&amp;#39;t need just to remove the password from the notification email, which can be achieved by editing the template in Control Panel / Configuration / Instance Settings / Email Notifications.  I&amp;#39;m really required to abolish the email sending.&lt;br /&gt;&lt;br /&gt;Something like the &amp;#34;Enabled&amp;#34; checkbox in the &amp;#34;Account Created&amp;#34; notification, but for the &amp;#34;Password Changed Notification&amp;#34;.&lt;br /&gt;&lt;br /&gt;Any ideas?&lt;br /&gt;&lt;br /&gt;TIA&lt;br /&gt;&lt;br /&gt;Fernando</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2017-10-24T21:26:37Z</dc:date>
  </entry>
</feed>
