Skip to content

Commit

Permalink
MDL-82365 mod_lesson: stricter equality checks of activity password.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden authored and ilyatregubov committed Aug 29, 2024
1 parent 8ec84f4 commit 3fc1073
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mod/lesson/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2864,15 +2864,17 @@ public function get_password_restriction_status($userpassword) {

if ($this->properties->usepassword && empty($USER->lessonloggedin[$this->id])) {
$correctpass = false;
if (!empty($userpassword) &&
(($this->properties->password == md5(trim($userpassword))) || ($this->properties->password == trim($userpassword)))) {

$userpassword = trim((string) $userpassword);
if ($userpassword !== '' &&
($this->properties->password === md5($userpassword) || $this->properties->password === $userpassword)) {
// With or without md5 for backward compatibility (MDL-11090).
$correctpass = true;
$USER->lessonloggedin[$this->id] = true;
} else if (isset($this->properties->extrapasswords)) {
// Group overrides may have additional passwords.
foreach ($this->properties->extrapasswords as $password) {
if (strcmp($password, md5(trim($userpassword))) === 0 || strcmp($password, trim($userpassword)) === 0) {
if ($password === md5($userpassword) || $password === $userpassword) {
$correctpass = true;
$USER->lessonloggedin[$this->id] = true;
}
Expand Down

0 comments on commit 3fc1073

Please sign in to comment.