diff --git a/addon/authenticators/torii.js b/addon/authenticators/torii.js index 0b9ec30b4..769062ece 100644 --- a/addon/authenticators/torii.js +++ b/addon/authenticators/torii.js @@ -1,6 +1,7 @@ import RSVP from 'rsvp'; import { assert } from '@ember/debug'; import { isPresent, isEmpty } from '@ember/utils'; +import { assign as emberAssign } from '@ember/polyfills'; import BaseAuthenticator from './base'; /** @@ -58,9 +59,9 @@ export default BaseAuthenticator.extend({ if (!isEmpty(data.provider)) { const { provider } = data; - return this.get('torii').fetch(data.provider, data).then((data) => { - this._authenticateWithProvider(provider, data); - return data; + return this.get('torii').fetch(data.provider, data).then((fetchedData) => { + this._authenticateWithProvider(provider, fetchedData); + return emberAssign(data, fetchedData); }, () => delete this._provider); } else { delete this._provider; diff --git a/tests/unit/authenticators/torii-test.js b/tests/unit/authenticators/torii-test.js index e81d336c7..a80b08431 100644 --- a/tests/unit/authenticators/torii-test.js +++ b/tests/unit/authenticators/torii-test.js @@ -40,9 +40,9 @@ describe('ToriiAuthenticator', () => { sinon.stub(torii, 'fetch').returns(RSVP.resolve({ some: 'other data' })); }); - it('returns a promise that resolves with the session data', function() { - return authenticator.restore({ some: 'data', provider: 'provider' }).then((data) => { - expect(data).to.eql({ some: 'other data', provider: 'provider' }); + it('returns a promise that resolves with the session data merged with the data fetched from torri', function() { + return authenticator.restore({ some: 'data', provider: 'provider', another: 'prop' }).then((data) => { + expect(data).to.eql({ some: 'other data', provider: 'provider', another: 'prop' }); }); }); });