From dbe2390e974ebcb0431e532e8a88567e9f923a80 Mon Sep 17 00:00:00 2001 From: Sujith Haridasan Date: Mon, 2 May 2022 11:33:40 +0530 Subject: [PATCH] MDL-74577 core: Reset login_failed_count_since_success after login When the user is logged in successfully then reset the value of login_failed_count_since_success to zero, if the value of login_failed_count_since_success is greater than zero. --- lib/outputrenderers.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 4b472ebe5fc..09ad2861604 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1147,21 +1147,19 @@ class core_renderer extends renderer_base { if (isset($SESSION->justloggedin)) { unset($SESSION->justloggedin); - if (!empty($CFG->displayloginfailures)) { - if (!isguestuser()) { - // Include this file only when required. - require_once($CFG->dirroot . '/user/lib.php'); - if ($count = user_count_login_failures($USER)) { - $loggedinas .= '
'; - $a = new stdClass(); - $a->attempts = $count; - $loggedinas .= get_string('failedloginattempts', '', $a); - if (file_exists("$CFG->dirroot/report/log/index.php") and has_capability('report/log:view', context_system::instance())) { - $loggedinas .= ' ('.html_writer::link(new moodle_url('/report/log/index.php', array('chooselog' => 1, - 'id' => 0 , 'modid' => 'site_errors')), get_string('logs')).')'; - } - $loggedinas .= '
'; + if (!isguestuser()) { + // Include this file only when required. + require_once($CFG->dirroot . '/user/lib.php'); + if (($count = user_count_login_failures($USER)) && !empty($CFG->displayloginfailures)) { + $loggedinas .= '
'; + $a = new stdClass(); + $a->attempts = $count; + $loggedinas .= get_string('failedloginattempts', '', $a); + if (file_exists("$CFG->dirroot/report/log/index.php") and has_capability('report/log:view', context_system::instance())) { + $loggedinas .= ' ('.html_writer::link(new moodle_url('/report/log/index.php', array('chooselog' => 1, + 'id' => 0 , 'modid' => 'site_errors')), get_string('logs')).')'; } + $loggedinas .= '
'; } } }