Skip to content

Commit 2d036d6

Browse files
committed
[#453] Ignore unknown factors when calculating passing score in grace mode
1 parent 29963a6 commit 2d036d6

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

classes/manager.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,10 @@ public static function possible_factor_setup() {
812812
}
813813

814814
/**
815-
* Gets current user weight, up until first unknown factor.
815+
* Gets current user weight
816+
* @param bool $stoponunknown if true, will stop on the first unknown facotr.
816817
*/
817-
public static function get_cumulative_weight() {
818+
public static function get_cumulative_weight($stoponunknown = true) {
818819
$factors = \tool_mfa\plugininfo\factor::get_active_user_factor_types();
819820
$totalweight = 0;
820821
foreach ($factors as $factor) {
@@ -824,7 +825,7 @@ public static function get_cumulative_weight() {
824825
if ($totalweight >= 100) {
825826
break;
826827
}
827-
} else if ($factor->get_state() == \tool_mfa\plugininfo\factor::STATE_UNKNOWN) {
828+
} else if ($stoponunknown && $factor->get_state() == \tool_mfa\plugininfo\factor::STATE_UNKNOWN) {
828829
break;
829830
}
830831
}

factor/grace/classes/factor.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ public function get_state($redirectable = true) {
135135
}
136136

137137
// We should never redirect if we have already passed.
138-
if ($redirectable && \tool_mfa\manager::get_cumulative_weight() >= 100) {
138+
// Do not stop on unknown, to avoid factors e.g. login banner from
139+
// hiding passing factors lower down in the list.
140+
if ($redirectable && \tool_mfa\manager::get_cumulative_weight(false) >= 100) {
139141
$redirectable = false;
140142
}
141143

0 commit comments

Comments
 (0)