Skip to content

Commit

Permalink
fix: corrected check on 2FA token (#2943)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed May 6, 2024
1 parent 6a0a17a commit 5a2b537
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions phpmyfaq/admin/index.php
Expand Up @@ -138,12 +138,11 @@
$faqusername = Filter::filterInput(INPUT_POST, 'faqusername', FILTER_SANITIZE_SPECIAL_CHARS);
$faqpassword = Filter::filterInput(INPUT_POST, 'faqpassword', FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_NO_ENCODE_QUOTES);
$faqremember = Filter::filterInput(INPUT_POST, 'faqrememberme', FILTER_SANITIZE_SPECIAL_CHARS);

$token = Filter::filterInput(INPUT_POST, 'token', FILTER_SANITIZE_SPECIAL_CHARS);
$userid = Filter::filterInput(INPUT_POST, 'userid', FILTER_VALIDATE_INT);

//
// Logging user in if twofactor is enabled and token is given and validated, if not: returns error message
// Logging user in if 2FA is enabled and token is given and validated, if not: returns error message
//
if (!is_null($token) && !is_null($userid)) {
$user = new CurrentUser($faqConfig);
Expand Down
8 changes: 4 additions & 4 deletions phpmyfaq/index.php
Expand Up @@ -144,12 +144,12 @@
}

//
// Validating token from 2FA if given; else: returns error message
// Logging user in if 2FA is enabled and token is given and validated, if not: returns error message
//
if ($token !== '' && !is_null($userid)) {
if (!is_null($token) && !is_null($userid)) {
$user = new CurrentUser($faqConfig);
$user->getUserById($userid);
if (strlen((string) $token) === 6 && is_numeric((string) $token)) {
$user = new CurrentUser($faqConfig);
$user->getUserById($userid);
$tfa = new TwoFactor($faqConfig);
$res = $tfa->validateToken($token, $userid);
if (!$res) {
Expand Down

0 comments on commit 5a2b537

Please sign in to comment.