app/public/sign.js in clarion-0.2.1 vs app/public/sign.js in clarion-0.3.0
- old
+ new
@@ -16,12 +16,41 @@
let appId = processionElem.attributes['data-app-id'].value;
let reqId = processionElem.attributes['data-req-id'].value;
let requests = JSON.parse(processionElem.attributes['data-requests'].value);
let challenge = JSON.parse(processionElem.attributes['data-challenge'].value);
+ let requestCancel = (e) => {
+ if (e) e.preventDefault();
+ let payload = JSON.stringify({
+ req_id: reqId,
+ });
+ let handleError = (err) => {
+ console.log(err);
+ processionElem.className = 'procession_error';
+ };
+
+ fetch(`/ui/cancel/${authnId}`, {credentials: 'include', method: 'POST', body: payload}).then((resp) => {
+ console.log(resp);
+ if (!resp.ok) {
+ processionElem.className = 'procession_error';
+ return;
+ }
+ return resp.json().then((json) => {
+ console.log(json);
+ if (json.ok) {
+ processionElem.className = 'procession_cancel';
+ } else {
+ processionElem.className = 'procession_error';
+ }
+ });
+ }).catch(handleError);
+ };
+ document.getElementById("cancel_link").addEventListener("click", requestCancel);
+
let processCallback = (json) => {
processionElem.className = 'procession_ok';
+ if (window.opener) window.close();
}
let cb = (response) => {
console.log(response);