diff --git a/system/modules/auth/actions/forgotpassword.php b/system/modules/auth/actions/forgotpassword.php index e19a26f12..b9f01a678 100755 --- a/system/modules/auth/actions/forgotpassword.php +++ b/system/modules/auth/actions/forgotpassword.php @@ -1,5 +1,7 @@ dt_password_reset_at = time(); $user->update(); + // default 30 minutes + $expiry = Config::get("auth.login.password.reset_token_expiry", 30 * 60); + $readable_expiry = CarbonInterval::seconds($expiry)->cascade()->forHumans(); + // Send email $message = "Hello {$user->getFullName()},\n
"; $message .= "Please go to this link to reset your password:
\n"; - $message .= "email}&token={$user->password_reset_token}\">https://" - . $_SERVER["HTTP_HOST"] . "/auth/resetpassword?token={$user->password_reset_token}\n
You have 24 hours to reset your password.

"; + $message .= "password_reset_token}\">https://" + . $_SERVER["HTTP_HOST"] . "/auth/resetpassword?token={$user->password_reset_token}\n
You have {$readable_expiry} to reset your password.

"; $message .= "Thank you,\n
". Config::get('main.company_name', 'Cosine'); $result = MailService::getInstance($w)->sendMail($user_contact->email, $support_email, Config::get("main.application_name") . " password reset", $message); diff --git a/system/modules/auth/actions/resetpassword.php b/system/modules/auth/actions/resetpassword.php index 39e041a47..f8aa079bb 100755 --- a/system/modules/auth/actions/resetpassword.php +++ b/system/modules/auth/actions/resetpassword.php @@ -1,5 +1,6 @@ id)) { // Check that the password reset hasn't expired LogService::getInstance($w)->setLogger("AUTH")->debug("USER: " . $user->id . " TIME: " . time() . " USER_RESET: " . $user->dt_password_reset_at . " RESULT: " . (time() - $user->dt_password_reset_at)); - if ((time() - $user->dt_password_reset_at) > 86400) { - $w->msg("Your token has expired (max 24 hours), please submit for a new one", "/auth/forgotpassword"); + + // default 30 minutes + $expiry = Config::get("auth.login.password.reset_token_expiry", 30 * 60); + $readable_expiry = CarbonInterval::seconds($expiry)->cascade()->forHumans(); + + if ((time() - $user->dt_password_reset_at) > $expiry) { + $w->msg("Your token has expired (max {$readable_expiry}), please submit for a new one", "/auth/forgotpassword"); return; } diff --git a/system/modules/auth/config.php b/system/modules/auth/config.php index 716a6a5ed..eb1d7bc48 100755 --- a/system/modules/auth/config.php +++ b/system/modules/auth/config.php @@ -16,7 +16,8 @@ 'login' => [ 'password' => [ 'enforce_length' => false, - 'min_length' => 8 + 'min_length' => 8, + "reset_token_expiry" => 30 * 60 // 30 minutes ], 'attempts' => [ 'track_attempts' => false,