Skip to content

Commit

Permalink
LPS-108642 Once change the password, we need to invalidate the passwo…
Browse files Browse the repository at this point in the history
…rd reset link
  • Loading branch information
yxingwu authored and brianchandotcom committed Mar 13, 2020
1 parent 79859a3 commit 8f072ee
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4808,6 +4808,8 @@ public User updatePassword(
null, ServiceContextThreadLocal.getServiceContext());
}

_invalidateTicket(user.getCompanyId(), User.class.getName(), userId);

return user;
}

Expand Down Expand Up @@ -4839,7 +4841,11 @@ public User updatePasswordManually(
user.setPasswordModifiedDate(passwordModifiedDate);
user.setDigest(user.getDigest(password));

return userPersistence.update(user);
user = userPersistence.update(user);

_invalidateTicket(user.getCompanyId(), User.class.getName(), userId);

return user;
}

/**
Expand Down Expand Up @@ -6890,6 +6896,23 @@ private String _getLocalizedValue(
return localizedValueMap.get(fallbackLocale);
}

private void _invalidateTicket(
long companyId, String className, long classPK)
throws PortalException {

List<Ticket> tickets = ticketLocalService.getTickets(
companyId, className, classPK, TicketConstants.TYPE_PASSWORD);

for (Ticket ticket : tickets) {
if (!ticket.isExpired()) {
ticketLocalService.updateTicket(
ticket.getTicketId(), className, classPK,
TicketConstants.TYPE_PASSWORD, ticket.getExtraInfo(),
new Date());
}
}
}

private void _sendNotificationEmail(
String fromAddress, String fromName, String toAddress, User toUser,
String subject, String body,
Expand Down

0 comments on commit 8f072ee

Please sign in to comment.