Skip to content

Instantly share code, notes, and snippets.

@dehuszar
Created November 8, 2016 15:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dehuszar/bcd2736b8be60c0f57c39f08393daf14 to your computer and use it in GitHub Desktop.
Save dehuszar/bcd2736b8be60c0f57c39f08393daf14 to your computer and use it in GitHub Desktop.
Use to extract extra values from your token
/* Usage
* {{detokenize 'extraValue'}} */
import Ember from 'ember';
const { get, inject } = Ember;
export default Ember.Helper.extend({
session: inject.service(),
compute(params) {
let token = get(this, 'session.data.authenticated.token'),
tokenData = JSON.parse(atob(token.split('.')[1]));
return tokenData[params];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment