diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 93ca97dc41d..d2b6ea8f26e 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -133,6 +133,15 @@ if (empty($reshook)) { $result = $edituser->fetch('', '', '', 1, $conf->entity, $username); } + // If the user does not have the right to change his own password + if ($result > 0) { + $edituser->getrights('user'); + if (!$edituser->hasRight('user', 'self', 'password')) { + $result = 0; + $edituser->error = 'USERNOTALLOWEDTOCHANGEPASS'; + } + } + // Set the message to show (must be the same if login/email exists or not // to avoid to guess them. $messagewarning = '
'; @@ -143,7 +152,7 @@ if (empty($reshook)) { } $messagewarning .= '
'; - if ($result <= 0 && $edituser->error == 'USERNOTFOUND') { + if ($result <= 0 && ($edituser->error == 'USERNOTFOUND' || $edituser->error == 'USERNOTALLOWEDTOCHANGEPASS')) { usleep(20000); // add delay to simulate setPassword() and send_password() actions delay (0.02s) $message .= $messagewarning; $username = '';