Last active
May 20, 2016 22:22
-
-
Save mrinterweb/c866f732697b0eb23d12e9cdc1ddf836 to your computer and use it in GitHub Desktop.
This file contains 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'; | |
import SessionService from 'ember-simple-auth/services/session'; | |
export default SessionService.reopen({ | |
jwt: {}, | |
// my problem is with this computed property. It is defined as a computed property, | |
// but when accessed, it is always undefined | |
isAdmin: Ember.computed('jwt', function() { | |
debugger; // this line is never hit | |
!!this.get('jwt.is_admin'); | |
}), | |
_jwtObserver: Ember.observer('data.authenticated', Ember.on('init', function() { | |
const accessToken = this.get('data.authenticated.access_token'); | |
if (!Ember.isBlank(accessToken)) { | |
if (Ember.isBlank(accessToken)) { return; } | |
let parts = accessToken.split('.'), | |
json = window.atob(parts[1]), | |
hash = JSON.parse(json); | |
this.set('jwt', hash); | |
} | |
})) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment