Created
April 14, 2016 20:47
-
-
Save kitlangton/25da1abc126ad996e11aeca736d61abb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { inject: { service }, RSVP } = Ember; | |
export default Ember.Service.extend({ | |
session: service(), | |
store: service(), | |
loadCurrentUser() { | |
return new RSVP.Promise((resolve, reject) => { | |
const accountId = this.get('session.data.authenticated.id'); | |
if (!Ember.isEmpty(accountId)) { | |
return this.get('store').find('user', accountId).then((account) => { | |
this.set('currentUser', account); | |
resolve(); | |
}, reject); | |
} else { | |
resolve(); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment