diff --git a/addons/api/addon/models/account.js b/addons/api/addon/models/account.js index 4a6ee08c2..4f880e07d 100644 --- a/addons/api/addon/models/account.js +++ b/addons/api/addon/models/account.js @@ -13,12 +13,14 @@ export default class AccountModel extends GeneratedAccountModel { @fragment('fragment-account-attributes', { defaultValue: {} }) attributes; /** - * Convenience for getting login_name attribute. + * Convenience for getting username in account. * @type {string} */ - @computed('attributes.login_name') + @computed('attributes') get username() { - return this.attributes.login_name; + if(this.type === 'password') { + return this.attributes.login_name; + } } // =methods diff --git a/addons/api/tests/unit/models/account-test.js b/addons/api/tests/unit/models/account-test.js index b8ce36b45..f6cbfbcc5 100644 --- a/addons/api/tests/unit/models/account-test.js +++ b/addons/api/tests/unit/models/account-test.js @@ -10,7 +10,7 @@ module('Unit | Model | account', function (hooks) { assert.ok(model); }); - test('it has an username attribute', function (assert) { + test('it has an username attribute for password account', function (assert) { assert.expect(2); const store = this.owner.lookup('service:store'); let model = store.createRecord('account', { @@ -21,4 +21,5 @@ module('Unit | Model | account', function (hooks) { model.attributes.login_name = 'username'; assert.equal(model.username, 'username'); }); + });