blob: f21d18e15d2afe6c42802f2354bb081ca024cb32 [file] [log] [blame]
<?php
/*
* hores
* Copyright (c) 2023 Adrià Vilanova Martínez
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program.
* If not, see http://www.gnu.org/licenses/.
*/
require_once("core.php");
if (security::userType() !== security::UNKNOWN || !isset($_SESSION["firstfactorid"]) || !secondFactor::isEnabled($_SESSION["firstfactorid"])) {
security::goHome();
}
secondFactor::checkAvailability();
$hasSecurityKeys = secondFactor::hasSecurityKeys($_SESSION["firstfactorid"]);
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $conf["appName"]; ?></title>
<?php visual::includeHead(); ?>
<link rel="stylesheet" href="css/index.css">
<style>
.login {
max-width: 500px;
}
.mdl-tabs__tab-bar {
height: auto;
}
.mdl-tabs__tab {
overflow: visible;
height: 100%;
line-height: 1.5;
padding-top: 14px;
padding-bottom: 14px;
}
.mdl-tabs__panel {
padding-top: 16px;
}
#content .mdl-spinner {
margin: 16px auto;
}
#webauthn {
text-align: center;
}
</style>
</head>
<?php visual::printBodyTag(); ?>
<div class="login mdl-shadow--4dp">
<h2>Verificación en dos pasos</h2>
<div id="content">
<div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect">
<div class="mdl-tabs__tab-bar">
<a href="#totp" class="mdl-tabs__tab<?=($hasSecurityKeys ? "" : " is-active")?>">Código de verificación</a>
<?php if ($hasSecurityKeys) { ?><a href="#webauthn" class="mdl-tabs__tab is-active">Llave de seguridad</a><?php } ?>
</div>
<div class="mdl-tabs__panel<?=($hasSecurityKeys ? "" : " is-active")?>" id="totp">
<p>Introduce el código de verificación generado por tu aplicación para móviles.</p>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" name="code" id="code" autocomplete="off" inputmode="numeric" pattern="[0-9]{6}" data-required>
<label class="mdl-textfield__label" for="code">Código de verificación</label>
</div>
<br>
<button id="verify" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Verificar</button>
</div>
<?php
if ($hasSecurityKeys) {
?>
<div class="mdl-tabs__panel is-active" id="webauthn">
<p>Cuando estés listo para autenticarte, pulsa el siguiente botón:</p>
<button id="startwebauthn" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Usar llave de seguridad</button>
</div>
<?php
}
?>
</div>
</div>
</div>
<div class="mdl-snackbar mdl-js-snackbar">
<div class="mdl-snackbar__text"></div>
<button type="button" class="mdl-snackbar__action"></button>
</div>
<script src="js/common_webauthn.js"></script>
<script src="js/secondfactor.js"></script>
</body>
</html>