Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::WORKER); |
| 4 | security::checkWorkerUIEnabled(); |
| 5 | secondFactor::checkAvailability(); |
| 6 | |
| 7 | $mdHeaderRowBefore = visual::backBtn("security.php"); |
| 8 | ?> |
| 9 | <!DOCTYPE html> |
| 10 | <html> |
| 11 | <head> |
| 12 | <title><?php echo $conf["appName"]; ?></title> |
| 13 | <?php visual::includeHead(); ?> |
| 14 | <link rel="stylesheet" href="css/dashboard.css"> |
| 15 | |
| 16 | <style> |
| 17 | .addsecuritykey { |
| 18 | position: fixed; |
| 19 | bottom: 16px; |
| 20 | right: 16px; |
| 21 | z-index: 1000; |
| 22 | } |
| 23 | </style> |
| 24 | </head> |
| 25 | <?php visual::printBodyTag(); ?> |
| 26 | <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer"> |
| 27 | <button class="addsecuritykey mdl-button md-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--accent"><i class="material-icons">add</i><span class="mdl-ripple"></span></button> |
| 28 | <?php visual::includeNav(); ?> |
| 29 | <main class="mdl-layout__content"> |
| 30 | <div class="page-content"> |
| 31 | <div class="main mdl-shadow--4dp"> |
| 32 | <h2>Llaves de seguridad</h2> |
| 33 | <?php |
| 34 | $securityKeys = secondFactor::getSecurityKeys(); |
| 35 | if ($securityKeys === false) { |
| 36 | echo "<p>Ha ocurrido un error inesperado y no se ha podido obtener un listado de tus llaves de seguridad.</p>"; |
| 37 | } elseif (count($securityKeys)) { |
| 38 | ?> |
| 39 | <div class="overflow-wrapper overflow-wrapper--for-table"> |
| 40 | <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp"> |
| 41 | <thead> |
| 42 | <tr> |
| 43 | <th class="mdl-data-table__cell--non-numeric">Nombre</th> |
| 44 | <th class="mdl-data-table__cell--non-numeric">Fecha de registro</th> |
| 45 | <th class="mdl-data-table__cell--non-numeric">Último uso</th> |
| 46 | <th class="mdl-data-table__cell--non-numeric"></th> |
| 47 | </tr> |
| 48 | </thead> |
| 49 | <tbody> |
| 50 | <?php |
| 51 | foreach ($securityKeys as $s) { |
| 52 | ?> |
| 53 | <tr> |
| 54 | <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($s["name"])?></td> |
| 55 | <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($s["added"] !== null ? date("d/m/Y H:i", $s["added"]) : "-")?></td> |
| 56 | <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($s["lastused"] !== null ? date("d/m/Y H:i", $s["lastused"]) : "-")?></td> |
| 57 | <td class='mdl-data-table__cell--non-numeric'><a href='dynamic/deletesecuritykey.php?id=<?=(int)$s["id"]?>' data-dyndialog-href='dynamic/deletesecuritykey.php?id=<?=(int)$s["id"]?>' title='Eliminar llave de seguridad'><i class='material-icons icon'>delete</i></a></td> |
| 58 | </tr> |
| 59 | <?php |
| 60 | } |
| 61 | ?> |
| 62 | </tbody> |
| 63 | </table> |
| 64 | </div> |
| 65 | <?php |
| 66 | } else { |
| 67 | ?> |
| 68 | <p>Todavía no has añadido ninguna llave de seguridad.</p> |
| 69 | <p>Puedes añadir una haciendo clic en el botón de la esquina inferior derecha de la página.</p> |
| 70 | <?php |
| 71 | } |
| 72 | ?> |
| 73 | </div> |
| 74 | </div> |
| 75 | </main> |
| 76 | </div> |
| 77 | |
| 78 | <dialog class="mdl-dialog" id="addsecuritykey"> |
| 79 | <form method="POST" id="addsecuritykeyform"> |
| 80 | <h4 class="mdl-dialog__title">Añadir llave de seguridad</h4> |
| 81 | <div class="mdl-dialog__content"> |
| 82 | <p>Introduce un nombre para la llave de seguridad y haz clic en el botón añadir para empezar el proceso de registro:</p> |
| 83 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 84 | <input class="mdl-textfield__input" type="text" name="name" id="name" autocomplete="off" data-required> |
| 85 | <label class="mdl-textfield__label" for="name">Nombre</label> |
| 86 | </div> |
| 87 | </div> |
| 88 | <div class="mdl-dialog__actions"> |
| 89 | <button id="registersecuritykey" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Registrar</button> |
| 90 | <button onclick="event.preventDefault(); document.querySelector('#addsecuritykey').close();" class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button> |
| 91 | </div> |
| 92 | </form> |
| 93 | </dialog> |
| 94 | |
| 95 | <?php |
| 96 | visual::smartSnackbar([ |
| 97 | ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."], |
| 98 | ["empty", "Faltan datos por introducir en el formulario."], |
| 99 | ["securitykeyadded", "Se ha registrado correctamente la llave de seguridad."], |
| 100 | ["securitykeydeleted", "Se ha eliminado correctamente la llave de seguridad."] |
| 101 | ]); |
| 102 | ?> |
| 103 | |
| 104 | <script src="js/common_webauthn.js"></script> |
| 105 | <script src="js/securitykeys.js"></script> |
| 106 | </body> |
| 107 | </html> |