diff --git a/js/pollTransaction.worker.js b/js/pollTransaction.worker.js index 1d1400d..9e08582 100644 --- a/js/pollTransaction.worker.js +++ b/js/pollTransaction.worker.js @@ -18,20 +18,15 @@ self.addEventListener('message', function (e) { setInterval(function () { - const request = new XMLHttpRequest(); - - request.open("GET", url + "?" + params, false); - - request.onload = (e) => - { - try + fetch(url + "?" + params, {method: 'GET'}) + .then(r => { - if (request.readyState === 4) + if (r.ok) { - if (request.status === 200) + r.text().then(result => { - const response = JSON.parse(request.response); - if (response['result']['authentication'] === "ACCEPT") + const resultJson = JSON.parse(result); + if (resultJson['result']['authentication'] === "ACCEPT") { self.postMessage({ 'message': 'Polling in browser: Push message confirmed!', @@ -39,28 +34,20 @@ self.addEventListener('message', function (e) }); self.close(); } - } - else - { - self.postMessage({'message': request.statusText, 'status': 'error'}); - self.close(); - } + }); } - } - catch (e) - { - self.postMessage({'message': e, 'status': 'error'}); - self.close(); - } - }; - - request.onerror = (e) => - { - self.postMessage({'message': request.statusText, 'status': 'error'}); - self.close(); - }; - - request.send(); + else + { + self.postMessage({'message': r.statusText, 'status': 'error'}); + self.close(); + } + }) + .catch(e => + { + self.postMessage({'message': e, 'status': 'error'}); + self.close(); + } + ); }, 300); } break; diff --git a/lib/Provider/PrivacyIDEAProvider.php b/lib/Provider/PrivacyIDEAProvider.php index dbce268..b54d17a 100644 --- a/lib/Provider/PrivacyIDEAProvider.php +++ b/lib/Provider/PrivacyIDEAProvider.php @@ -91,31 +91,34 @@ public function getTemplate(IUser $user): Template if ($authenticationFlow === "piAuthFlowTriggerChallenge") { - if (!$this->pi->serviceAccountAvailable()) + if (!empty($this->pi)) { - $this->log("error", "Service account name or password is not set in config. Cannot trigger the challenges."); - } - else - { - if ($this->session->get("piTriggerChallengeDone") !== true) + if (!$this->pi->serviceAccountAvailable()) { - try + $this->log("error", "Service account name or password is not set in config. Cannot trigger the challenges."); + } + else + { + if ($this->session->get("piTriggerChallengeDone") !== true) { - $response = $this->pi->triggerChallenge($username, $headers); - $this->session->set("piTriggerChallengeDone", true); - if ($response !== null) + try { - $this->processPIResponse($response); + $response = $this->pi->triggerChallenge($username, $headers); + $this->session->set("piTriggerChallengeDone", true); + if ($response !== null) + { + $this->processPIResponse($response); + } + else + { + $this->log("error", "No response from privacyIDEA server for triggerchallenge."); + } } - else + catch (PIBadRequestException $e) { - $this->log("error", "No response from privacyIDEA server for triggerchallenge."); + $this->handlePIException($e); } } - catch (PIBadRequestException $e) - { - $this->handlePIException($e); - } } } } diff --git a/package.json b/package.json index ee914cd..ff89edb 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,7 @@ "extends @nextcloud/browserslist-config" ], "dependencies": { - "@nextcloud/router": "^3.0.1", - "@nextcloud/vue": "^8.11.2", - "vue": "^2.7.16" + "@nextcloud/router": "^3.0.1" }, "devDependencies": { "@nextcloud/browserslist-config": "^3.0.1",