Verify 2fa token properly

This commit is contained in:
Johannes Rauh 2025-10-02 08:25:20 +02:00
parent 2471231d01
commit 3cc2bdc229

View file

@ -44,10 +44,9 @@ class Challenge2FAForm extends LoginForm
public function onSuccess()
{
// TODO: Implement proper 2FA code validation
$user = Auth::getInstance()->getUser();
$totp = IcingaTotp::loadFromDb($this->getDb(), $user->getUsername());
if ($totp->verify($_POST['token'])) {
if ($this->getElement('token') && $totp->verify($this->getValue('token'))) {
$auth = Auth::getInstance();
$user = $auth->getUser();
$user->setTwoFactorSuccessful(true);