Skip to content

Instantly share code, notes, and snippets.

@mrinterweb
Last active May 20, 2016 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrinterweb/c866f732697b0eb23d12e9cdc1ddf836 to your computer and use it in GitHub Desktop.
Save mrinterweb/c866f732697b0eb23d12e9cdc1ddf836 to your computer and use it in GitHub Desktop.
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