Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
Adrià Vilanova Martínez | 5af8651 | 2023-12-02 20:44:16 +0100 | [diff] [blame] | 2 | /* |
| 3 | * hores |
| 4 | * Copyright (c) 2023 Adrià Vilanova Martínez |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Affero General Public License as |
| 8 | * published by the Free Software Foundation, either version 3 of the |
| 9 | * License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Affero General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Affero General Public |
| 17 | * License along with this program. |
| 18 | * If not, see http://www.gnu.org/licenses/. |
| 19 | */ |
| 20 | |
Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 21 | require_once("core.php"); |
| 22 | |
| 23 | if (security::userType() !== security::UNKNOWN || !isset($_SESSION["firstfactorid"]) || !secondFactor::isEnabled($_SESSION["firstfactorid"])) { |
| 24 | security::goHome(); |
| 25 | } |
| 26 | |
| 27 | secondFactor::checkAvailability(); |
| 28 | |
| 29 | $hasSecurityKeys = secondFactor::hasSecurityKeys($_SESSION["firstfactorid"]); |
| 30 | ?> |
| 31 | <!DOCTYPE html> |
| 32 | <html> |
| 33 | <head> |
| 34 | <title><?php echo $conf["appName"]; ?></title> |
| 35 | <?php visual::includeHead(); ?> |
| 36 | <link rel="stylesheet" href="css/index.css"> |
| 37 | <style> |
| 38 | .login { |
| 39 | max-width: 500px; |
| 40 | } |
| 41 | |
| 42 | .mdl-tabs__tab-bar { |
| 43 | height: auto; |
| 44 | } |
| 45 | |
| 46 | .mdl-tabs__tab { |
| 47 | overflow: visible; |
| 48 | height: 100%; |
| 49 | line-height: 1.5; |
| 50 | padding-top: 14px; |
| 51 | padding-bottom: 14px; |
| 52 | } |
| 53 | |
| 54 | .mdl-tabs__panel { |
| 55 | padding-top: 16px; |
| 56 | } |
| 57 | |
| 58 | #content .mdl-spinner { |
| 59 | margin: 16px auto; |
| 60 | } |
| 61 | |
| 62 | #webauthn { |
| 63 | text-align: center; |
| 64 | } |
| 65 | </style> |
| 66 | </head> |
| 67 | <?php visual::printBodyTag(); ?> |
| 68 | <div class="login mdl-shadow--4dp"> |
| 69 | <h2>Verificación en dos pasos</h2> |
| 70 | <div id="content"> |
| 71 | <div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect"> |
| 72 | <div class="mdl-tabs__tab-bar"> |
| 73 | <a href="#totp" class="mdl-tabs__tab<?=($hasSecurityKeys ? "" : " is-active")?>">Código de verificación</a> |
| 74 | <?php if ($hasSecurityKeys) { ?><a href="#webauthn" class="mdl-tabs__tab is-active">Llave de seguridad</a><?php } ?> |
| 75 | </div> |
| 76 | |
| 77 | <div class="mdl-tabs__panel<?=($hasSecurityKeys ? "" : " is-active")?>" id="totp"> |
| 78 | <p>Introduce el código de verificación generado por tu aplicación para móviles.</p> |
| 79 | |
| 80 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 81 | <input class="mdl-textfield__input" type="text" name="code" id="code" autocomplete="off" inputmode="numeric" pattern="[0-9]{6}" data-required> |
| 82 | <label class="mdl-textfield__label" for="code">Código de verificación</label> |
| 83 | </div> |
| 84 | <br> |
| 85 | <button id="verify" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Verificar</button> |
| 86 | </div> |
| 87 | |
| 88 | <?php |
| 89 | if ($hasSecurityKeys) { |
| 90 | ?> |
| 91 | <div class="mdl-tabs__panel is-active" id="webauthn"> |
| 92 | <p>Cuando estés listo para autenticarte, pulsa el siguiente botón:</p> |
| 93 | |
| 94 | <button id="startwebauthn" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Usar llave de seguridad</button> |
| 95 | </div> |
| 96 | <?php |
| 97 | } |
| 98 | ?> |
| 99 | </div> |
| 100 | </div> |
| 101 | </div> |
| 102 | |
| 103 | <div class="mdl-snackbar mdl-js-snackbar"> |
| 104 | <div class="mdl-snackbar__text"></div> |
| 105 | <button type="button" class="mdl-snackbar__action"></button> |
| 106 | </div> |
| 107 | |
| 108 | <script src="js/common_webauthn.js"></script> |
| 109 | <script src="js/secondfactor.js"></script> |
| 110 | </body> |
| 111 | </html> |