Skip to content

Commit

Permalink
Merge pull request #311 from evoactivity/remove-use-of-assign-polyfill
Browse files Browse the repository at this point in the history
Remove use of assign polyfill
  • Loading branch information
fenichelar authored Sep 8, 2022
2 parents 275e692 + 64eae90 commit 2a473b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions addon/authenticators/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import EmberObject, { get } from '@ember/object';
import { getOwner } from '@ember/application';
import { assign } from '@ember/polyfills';
import { Promise, resolve } from 'rsvp';
import { isEmpty } from '@ember/utils';
import { cancel, later } from '@ember/runloop';
Expand Down Expand Up @@ -134,7 +133,7 @@ export default TokenAuthenticator.extend({
@return {Promise} Promise that resolves when an auth token is successfully acquired from the server and rejects otherwise
*/
authenticate(credentials, headers) {
return this.makeRequest(this.serverTokenEndpoint, credentials, assign({}, this.headers, headers)).then(response => {
return this.makeRequest(this.serverTokenEndpoint, credentials, {...this.headers, ...headers}).then(response => {
return this.handleAuthResponse(response.json);
});
},
Expand Down Expand Up @@ -293,7 +292,7 @@ export default TokenAuthenticator.extend({
this.scheduleAccessTokenRefresh(expiresAt, refreshToken);
}

return assign(response, tokenExpireData, {tokenData: tokenData});
return {...response, ...tokenExpireData, tokenData: tokenData};
},

/**
Expand Down
10 changes: 5 additions & 5 deletions addon/authenticators/token.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import EmberObject from '@ember/object';
import { getOwner } from '@ember/application';
import fetch from 'fetch';
import { assign } from '@ember/polyfills';
import { Promise, reject, resolve } from 'rsvp';
import { isEmpty } from '@ember/utils';
import Base from 'ember-simple-auth/authenticators/base';
Expand Down Expand Up @@ -58,7 +57,7 @@ export default Base.extend({
@return {Promise} Promise that resolves when an auth token is successfully acquired from the server and rejects otherwise
*/
authenticate(credentials, headers) {
return this.makeRequest(this.serverTokenEndpoint, credentials, assign({}, this.headers, headers)).then(response => {
return this.makeRequest(this.serverTokenEndpoint, credentials, {...this.headers, ...headers}).then(response => {
return response.json;
});
},
Expand All @@ -83,10 +82,11 @@ export default Base.extend({
makeRequest(url, data, headers) {
return fetch(url, {
method: 'POST',
headers: assign({
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}, headers),
'Content-Type': 'application/json',
...headers
},
body: JSON.stringify(data)
}).then(response => {
const res = {
Expand Down

0 comments on commit 2a473b9

Please sign in to comment.