Skip to content

Commit

Permalink
Add default JSON headers to sign-out requests (#198)
Browse files Browse the repository at this point in the history
Add the enumerable values of `config.jsonHeaders` to `deleteHeaders`, rather than creating a new, empty object from its prototype.
  • Loading branch information
eatyourgreens authored Feb 19, 2023
1 parent 6a4d6f6 commit b88b424
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ const authClient = new Model({
return getCSRFToken(config.host).then(function(token) {
var url = config.host + '/users/sign_out';

var deleteHeaders = Object.create(config.jsonHeaders);
deleteHeaders['X-CSRF-Token'] = token;
var deleteHeaders = {
...config.jsonHeaders,
['X-CSRF-Token']: token
};

return makeCredentialHTTPRequest('DELETE', url, null, deleteHeaders)
.then(function() {
Expand Down
6 changes: 4 additions & 2 deletions lib/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ const authClient = new Model({
return getCSRFToken(config.oauthHost).then(function(token) {
var url = config.oauthHost + '/users/sign_out';

var deleteHeaders = Object.create(config.jsonHeaders);
deleteHeaders['X-CSRF-Token'] = token;
var deleteHeaders = {
...config.jsonHeaders,
['X-CSRF-Token']: token
};

return makeCredentialHTTPRequest('DELETE', url, null, deleteHeaders)
.then(function() {
Expand Down

0 comments on commit b88b424

Please sign in to comment.