getPassword(); $user = $_SESSION['ldap']->getUserName(); // get serials try { $service = new TwoFactorProviderService($config); $provider = $service->getProvider(); $serials = $provider->getSerials($user, $password); } catch (\Exception $e) { logNewMessage(LOG_ERR, 'Unable to get 2-factor serials for ' . $user . ' ' . $e->getMessage()); metaRefresh("login.php?2factor=error"); die(); } $twoFactorLabelConfig = $config->getTwoFactorAuthenticationLabel(); $twoFactorLabel = empty($twoFactorLabelConfig) ? _('PIN+Token') : $twoFactorLabelConfig; if (sizeof($serials) == 0) { if ($config->getTwoFactorAuthenticationOptional()) { unset($_SESSION['2factorRequired']); metaRefresh("main.php"); die(); } else { metaRefresh("login.php?2factor=noToken"); die(); } } if (isset($_POST['logout'])) { // destroy session session_destroy(); unset($_SESSION); // redirect to login page metaRefresh("login.php"); exit(); } if (isset($_POST['submit']) || isset($_POST['sig_response'])) { $twoFactorInput = isset($_POST['2factor']) ? $_POST['2factor'] : null; $serial = isset($_POST['serial']) ? $_POST['serial'] : null; if (!$provider->hasCustomInputForm() && (empty($twoFactorInput) || !in_array($serial, $serials))) { $errorMessage = _(sprintf('Please enter "%s".', $twoFactorLabel)); } else { $twoFactorValid = false; try { $twoFactorValid = $provider->verify2ndFactor($user, $password, $serial, $twoFactorInput); } catch (\Exception $e) { logNewMessage(LOG_WARNING, '2-factor verification failed: ' . $e->getMessage()); } if ($twoFactorValid) { unset($_SESSION['2factorRequired']); metaRefresh("main.php"); die(); } else { $errorMessage = _(sprintf('Verification failed.', $twoFactorLabel)); } } } echo $_SESSION['header']; printHeaderContents(_("Login"), '..'); ?>
LDAP Account Manager |