Skip to content

Commit

Permalink
Merge pull request #2542 from RobbieTheWagner/master
Browse files Browse the repository at this point in the history
Use Object.assign and drop Ember.assign
  • Loading branch information
BobrImperator authored Apr 21, 2023
2 parents 0b4bebb + cabd964 commit 7ddea3a
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 24 deletions.
5 changes: 2 additions & 3 deletions packages/ember-simple-auth/addon/authenticators/devise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Promise } from 'rsvp';
import { isEmpty } from '@ember/utils';
import { run } from '@ember/runloop';
import assign from 'ember-simple-auth/utils/assign';
import BaseAuthenticator from './base';
import fetch from 'fetch';

Expand Down Expand Up @@ -150,15 +149,15 @@ export default BaseAuthenticator.extend({
let url = options.url || this.get('serverTokenEndpoint');
let requestOptions = {};
let body = JSON.stringify(data);
assign(requestOptions, {
Object.assign(requestOptions, {
body,
method: 'POST',
headers: {
'accept': JSON_CONTENT_TYPE,
'content-type': JSON_CONTENT_TYPE
}
});
assign(requestOptions, options || {});
Object.assign(requestOptions, options || {});

return fetch(url, requestOptions);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { run, later, cancel } from '@ember/runloop';
import { A, makeArray } from '@ember/array';
import { warn } from '@ember/debug';
import { getOwner } from '@ember/application';
import assign from 'ember-simple-auth/utils/assign';
import Ember from 'ember';
import BaseAuthenticator from './base';
import fetch from 'fetch';
Expand Down Expand Up @@ -221,7 +220,7 @@ export default BaseAuthenticator.extend({
const expiresAt = this._absolutizeExpirationTime(response['expires_in']);
this._scheduleAccessTokenRefresh(response['expires_in'], expiresAt, response['refresh_token']);
if (!isEmpty(expiresAt)) {
response = assign(response, { 'expires_at': expiresAt });
response = Object.assign(response, { 'expires_at': expiresAt });
}

resolve(response);
Expand Down Expand Up @@ -349,7 +348,7 @@ export default BaseAuthenticator.extend({
expiresIn = response['expires_in'] || expiresIn;
refreshToken = response['refresh_token'] || refreshToken;
const expiresAt = this._absolutizeExpirationTime(expiresIn);
const data = assign(response, { 'expires_in': expiresIn, 'expires_at': expiresAt, 'refresh_token': refreshToken });
const data = Object.assign(response, { 'expires_in': expiresIn, 'expires_at': expiresAt, 'refresh_token': refreshToken });
this._scheduleAccessTokenRefresh(expiresIn, null, refreshToken);
this.trigger('sessionDataUpdated', data);
resolve(data);
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-simple-auth/addon/authenticators/torii.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import RSVP from 'rsvp';
import { assert, deprecate } from '@ember/debug';
import { isPresent, isEmpty } from '@ember/utils';
import assign from 'ember-simple-auth/utils/assign';
import BaseAuthenticator from './base';

deprecate('Ember Simple Auth: The Torii authenticator is deprecated.', false, {
Expand Down Expand Up @@ -73,7 +72,7 @@ export default BaseAuthenticator.extend({
return this.get('torii').fetch(data.provider, data).then(
(fetchedData) => {
this._authenticateWithProvider(provider, fetchedData);
return assign(data, fetchedData);
return Object.assign(data, fetchedData);
},
(err) => {
delete this._provider;
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-simple-auth/addon/internal-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import RSVP from 'rsvp';
import { isEmpty, isNone } from '@ember/utils';
import ObjectProxy from '@ember/object/proxy';
import Evented from '@ember/object/evented';
import assign from 'ember-simple-auth/utils/assign';
import { set } from '@ember/object';
import { debug, assert } from '@ember/debug';
import { getOwner, setOwner } from '@ember/application';
Expand Down Expand Up @@ -151,7 +150,7 @@ export default ObjectProxy.extend(Evented, {
_updateStore() {
let data = this.content;
if (!isEmpty(this.authenticator)) {
set(data, 'authenticated', assign({ authenticator: this.authenticator }, data.authenticated || {}));
set(data, 'authenticated', Object.assign({ authenticator: this.authenticator }, data.authenticated || {}));
}
return this.store.persist(data);
},
Expand Down
3 changes: 0 additions & 3 deletions packages/ember-simple-auth/addon/utils/assign.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Adaptive from 'ember-simple-auth/session-stores/adaptive';
import assign from 'ember-simple-auth/utils/assign';

export default function createAdaptiveStore(
cookiesService,
options = {},
owner
) {
owner.register('session-store:adaptive', Adaptive.extend(assign({
owner.register('session-store:adaptive', Adaptive.extend(Object.assign({
_isLocalStorageAvailable: false,
}, options)));

Expand Down
5 changes: 2 additions & 3 deletions packages/ember-simple-auth/tests/helpers/start-app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Application from '../../app';
import config from '../../config/environment';
import { run } from '@ember/runloop';
import assign from 'ember-simple-auth/utils/assign';

export default function startApp(attrs) {
let attributes = assign({}, config.APP);
let attributes = Object.assign({}, config.APP);
attributes.autoboot = true;
attributes = assign(attributes, attrs); // use defaults, but you can override;
attributes = Object.assign(attributes, attrs); // use defaults, but you can override;

return run(() => {
let application = Application.create(attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import itBehavesLikeAStore from './shared/store-behavior';
import itBehavesLikeACookieStore from './shared/cookie-store-behavior';
import FakeCookieService from '../../helpers/fake-cookie-service';
import createAdaptiveStore from '../../helpers/create-adaptive-store';
import assign from 'ember-simple-auth/utils/assign';

module('AdaptiveStore', function(hooks) {
setupTest(hooks);
Expand Down Expand Up @@ -57,7 +56,7 @@ module('AdaptiveStore', function(hooks) {
let cookieService = owner.lookup('service:cookies');
sinon.spy(cookieService, 'read');
sinon.spy(cookieService, 'write');
let store = createAdaptiveStore(cookieService, assign({
let store = createAdaptiveStore(cookieService, Object.assign({
_isLocalStorageAvailable: false,
_cookieName: 'test:session',
}, storeOptions), owner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import itBehavesLikeAStore from './shared/store-behavior';
import itBehavesLikeACookieStore from './shared/cookie-store-behavior';
import FakeCookieService from '../../helpers/fake-cookie-service';
import CookieStore from 'ember-simple-auth/session-stores/cookie';
import assign from 'ember-simple-auth/utils/assign';

module('CookieStore', function(hooks) {
setupTest(hooks);
Expand Down Expand Up @@ -39,7 +38,7 @@ module('CookieStore', function(hooks) {
let cookieService = owner.lookup('service:cookies');
sinon.spy(cookieService, 'read');
sinon.spy(cookieService, 'write');
owner.register('session-store:cookie', CookieStore.extend(assign({
owner.register('session-store:cookie', CookieStore.extend(Object.assign({
_cookieName: 'test:session',
}, storeOptions)));
let store = owner.lookup('session-store:cookie');
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-simple-auth/tests/unit/utils/assign-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { module, test } from 'qunit';
import assign from 'ember-simple-auth/utils/assign';

module('Unit | Utility | assign', function() {
test('it works', function(assert) {
let result = assign({ foo: 'foo' }, { bar: 'bar' });
let result = Object.assign({ foo: 'foo' }, { bar: 'bar' });

assert.deepEqual(result, { foo: 'foo', bar: 'bar' });
});
Expand Down

0 comments on commit 7ddea3a

Please sign in to comment.