Skip to content

Commit e36df3c

Browse files
amulet1ralflang
authored andcommitted
Allow to set a custom error message returned by OTPAuth module
1 parent 1f05979 commit e36df3c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

login.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,20 @@ function _addAnchor($url, $type, $vars, $url_anchor = null)
164164
if ($loginHandler->secondFactorSupported) {
165165
try {
166166
$authSecondFactor = (string) Horde_Util::getPost('horde_secondfactor');
167-
$passSecondFactor = $registry->call('secondfactor/checkInput', [
167+
$errorSecondFactor = $registry->call('secondfactor/blockLogin', [
168168
$authUser,
169169
$authSecondFactor,
170170
]);
171171
} catch (Horde_Exception $e) {
172+
$errorSecondFactor = Horde_Auth::REASON_BADLOGIN;
173+
}
174+
175+
if ($errorSecondFactor) {
172176
$passSecondFactor = false;
177+
$auth->setError($errorSecondFactor);
173178
}
174179
}
175-
// Security demands we do not allow the user to test the factors individually. Twofactor failure must look like a bad password.
176-
if (!$passSecondFactor) {
177-
$auth->setError(Horde_Auth::REASON_BADLOGIN);
178-
}
180+
179181
if ($passSecondFactor && $auth->authenticate($authUser, $auth_params)) {
180182
Horde::log(
181183
sprintf(

0 commit comments

Comments
 (0)