From 62d4b7a6a036d128395750bb4a258204d08fd29e Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Thu, 11 May 2017 09:49:24 -0700 Subject: [PATCH] Fix issue when loading the accounts page initially rancher/rancher#8422 --- app/components/settings/user-info/component.js | 13 +++++++++---- app/instance-initializers/identity.js | 18 ++++++++++++++++++ app/services/access.js | 11 ++++++----- 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 app/instance-initializers/identity.js diff --git a/app/components/settings/user-info/component.js b/app/components/settings/user-info/component.js index fb919b36e..a58c99331 100644 --- a/app/components/settings/user-info/component.js +++ b/app/components/settings/user-info/component.js @@ -1,11 +1,16 @@ import Ember from 'ember'; export default Ember.Component.extend({ - classNames: ['box'], - - access: Ember.inject.service(), - account: Ember.computed.alias('access.identity'), + classNames: ['box'], + access: Ember.inject.service(), modalService: Ember.inject.service('modal'), + account: null, + + didReceiveAttrs() { + this._super(...arguments); + this.set('account', this.get('access.identity')); + }, + actions: { editPassword() { this.get('account').send('edit'); diff --git a/app/instance-initializers/identity.js b/app/instance-initializers/identity.js new file mode 100644 index 000000000..a608e2333 --- /dev/null +++ b/app/instance-initializers/identity.js @@ -0,0 +1,18 @@ +import C from 'ui/utils/constants'; + +export function initialize(instance) { + var access = instance.lookup('service:access'); + var userStore = instance.lookup('service:user-store'); + var session = instance.lookup('service:session'); + var idnt = session.get(C.SESSION.IDENTITY) || {}; + + idnt.type = 'identity'; + + access.set('identity', userStore.createRecord(idnt)); +} + +export default { + name: 'identity', + after: ['user-store'], + initialize: initialize +}; diff --git a/app/services/access.js b/app/services/access.js index bbe2ea4f9..3dd61e1ce 100644 --- a/app/services/access.js +++ b/app/services/access.js @@ -23,11 +23,12 @@ export default Ember.Service.extend({ admin: null, // The identity from the session isn't an actual identity model... - identity: function() { - var obj = this.get('session.'+C.SESSION.IDENTITY) || {}; - obj.type = 'identity'; - return this.get('userStore').createRecord(obj); - }.property('session.'+C.SESSION.IDENTITY), + // identity: function() { + // var obj = this.get('session.'+C.SESSION.IDENTITY) || {}; + // obj.type = 'identity'; + // return this.get('userStore').createRecord(obj); + // }.property('session.'+C.SESSION.IDENTITY), + identity: null, testAuth() { // make a call to api base because it is authenticated