Skip to content

Commit

Permalink
Allow submission to send credentials
Browse files Browse the repository at this point in the history
TODO: tests
  • Loading branch information
DrRataplan committed Oct 31, 2023
1 parent 736463a commit 3f55810
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/fx-submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
: 'application/xml';

this.validate = this.getAttribute('validate') ? this.getAttribute('validate') : 'true';
this.credentials = this.hasAttribute('credentials')
? this.getAttribute('credentials')
: 'same-origin';
if (!['same-origin', 'include', 'omit'].includes(this.credentials)) {
console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`, this);
}
this.shadowRoot.innerHTML = this.renderHTML();
}

Expand Down Expand Up @@ -96,9 +102,8 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
_getProperty(attrName){
if(this.parameters.has(attrName)){
return this.parameters.get(attrName);
} else {
return this.getAttribute(attrName);
}
return this.getAttribute(attrName);
}

/**
Expand Down Expand Up @@ -191,10 +196,7 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
try {
const response = await fetch(resolvedUrl, {
method: this.method,
/*
mode: 'cors',
credentials: 'include',
*/
credentials: this.credentials,
headers,
body: serialized,
});
Expand Down

0 comments on commit 3f55810

Please sign in to comment.