MCPcopy Create free account
hub / github.com/hashintel/hash / submitConsentForm

Function submitConsentForm

apps/hash-api/public/consent.js:1–29  ·  view source on GitHub ↗
(submitValue)

Source from the content-addressed store, hash-verified

1function submitConsentForm(submitValue) {
2 var grantScope = document.querySelectorAll(
3 'input[name="grant_scope"]:checked',
4 );
5 var grantScopeValues = [];
6 for (var i = 0; i < grantScope.length; i++) {
7 grantScopeValues.push(grantScope[i].value);
8 }
9
10 var challenge = document.querySelector('input[name="challenge"]').value;
11 var csrfToken = document.querySelector('input[name="csrfToken"]').value;
12 var data = {
13 grant_scope: grantScopeValues,
14 submit: submitValue,
15 challenge: challenge,
16 csrfToken: csrfToken,
17 };
18 var xhr = new XMLHttpRequest();
19 xhr.open("POST", "/oauth2/consent");
20 xhr.setRequestHeader("Content-Type", "application/json");
21 xhr.onload = function () {
22 if (xhr.status === 200) {
23 window.location.href = JSON.parse(xhr.responseText).redirectTo;
24 } else {
25 alert("Something went wrong");
26 }
27 };
28 xhr.send(JSON.stringify(data));
29}
30
31function attachFormHandler() {
32 var form = document.querySelector("form");

Callers 1

attachFormHandlerFunction · 0.85

Calls 4

openMethod · 0.80
pushMethod · 0.65
sendMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected