From 4e329f1f55496155f6e8a6e0458c44ccc6ad26a4 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 10 Jan 2020 20:06:24 +0100 Subject: [PATCH] webauthn --- lam/templates/lib/500_lam.js | 11 ++++++++--- lam/templates/misc/ajax.php | 1 + lam/templates/tools/webauthn.php | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lam/templates/lib/500_lam.js b/lam/templates/lib/500_lam.js index 8b5b4d31..053b8aa0 100644 --- a/lam/templates/lib/500_lam.js +++ b/lam/templates/lib/500_lam.js @@ -1615,10 +1615,11 @@ window.lam.webauthn.removeDevice = function(event) { * Removes a user's own webauthn device. * * @param event click event + * @param isSelfService run in self service or admin context */ -window.lam.webauthn.removeOwnDevice = function(event) { +window.lam.webauthn.removeOwnDevice = function(event, isSelfService) { event.preventDefault(); - const element = jQuery(event.target); + const element = jQuery(event.currentTarget); const successCallback = function () { const form = jQuery("#webauthnform"); jQuery('').attr({ @@ -1628,7 +1629,11 @@ window.lam.webauthn.removeOwnDevice = function(event) { }).appendTo(form); form.submit(); }; - window.lam.webauthn.removeDeviceDialog(element, 'webauthnOwnDevices', successCallback); + let action = 'webauthnOwnDevices'; + if (isSelfService) { + action = action + '&selfservice=true&module=webauthn&scope=user'; + } + window.lam.webauthn.removeDeviceDialog(element, action, successCallback); return false; } diff --git a/lam/templates/misc/ajax.php b/lam/templates/misc/ajax.php index 3dd9df2e..ca5974ec 100644 --- a/lam/templates/misc/ajax.php +++ b/lam/templates/misc/ajax.php @@ -92,6 +92,7 @@ class Ajax { $module = new $_GET['module']($_GET['scope']); $module->handleAjaxRequest(); } + die(); } if (!isset($_GET['function'])) { die(); diff --git a/lam/templates/tools/webauthn.php b/lam/templates/tools/webauthn.php index fb07bdda..04147ada 100644 --- a/lam/templates/tools/webauthn.php +++ b/lam/templates/tools/webauthn.php @@ -115,7 +115,7 @@ else { $delButton->addDataAttribute('dialogtitle', _('Remove device')); $delButton->addDataAttribute('oktext', _('Ok')); $delButton->addDataAttribute('canceltext', _('Cancel')); - $delButton->setOnClick('window.lam.webauthn.removeOwnDevice(event);'); + $delButton->setOnClick('window.lam.webauthn.removeOwnDevice(event, false);'); $data[] = array( new htmlOutputText(date('Y-m-d H:i:s', $result['registrationTime'])), new htmlOutputText(date('Y-m-d H:i:s', $result['lastUseTime'])),