From 7e17d74b7a7926a46c81834a735599e7a37883c2 Mon Sep 17 00:00:00 2001 From: Boone B Gorges Date: Tue, 16 Jul 2024 15:00:25 -0500 Subject: [PATCH] Set user password expiration date on password reset. See #3406. --- .../wds-citytech/includes/passwords.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wp-content/plugins/wds-citytech/includes/passwords.php b/wp-content/plugins/wds-citytech/includes/passwords.php index e94a0fe275..ac5c8c0667 100644 --- a/wp-content/plugins/wds-citytech/includes/passwords.php +++ b/wp-content/plugins/wds-citytech/includes/passwords.php @@ -6,6 +6,15 @@ namespace OpenLab\Passwords; +/** + * Gets the password expiration interval. + * + * @return int The interval in seconds. + */ +function get_password_expiration_interval() { + return 180 * DAY_IN_SECONDS; +} + /** * Sets a user's password expiration date. * @@ -194,3 +203,15 @@ function password_expired_message( $message ) { return $message; } add_filter( 'login_message', __NAMESPACE__ . '\password_expired_message' ); + +/** + * Sets the user's password expiration date when they reset their password. + * + * @param \WP_User $user The user object. + * @return void + */ +function set_password_expiration_on_password_reset( $user ) { + $expiration = time() + get_password_expiration_interval(); + set_password_expiration( $user->ID, $expiration ); +} +add_action( 'after_password_reset', __NAMESPACE__ . '\set_password_expiration_on_password_reset' );