Skip to content

Commit

Permalink
Merge pull request #112 from xcambar/master
Browse files Browse the repository at this point in the history
Use Ember.get to fetch properties in JWT response
  • Loading branch information
jpadilla committed Dec 24, 2015
2 parents 53065aa + 6951907 commit a910d84
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions addon/authenticators/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export default TokenAuthenticator.extend({

this.makeRequest(this.serverTokenEndpoint, data, headers).then(response => {
Ember.run(() => {
const token = response[this.tokenPropertyName];
const token = Ember.get(response, this.tokenPropertyName);
const tokenData = this.getTokenData(token);
const expiresAt = tokenData[this.tokenExpireName];
const expiresAt = Ember.get(tokenData, this.tokenExpireName);
const tokenExpireData = {};

this.scheduleAccessTokenRefresh(expiresAt, token);
Expand Down Expand Up @@ -233,9 +233,9 @@ export default TokenAuthenticator.extend({
return new Ember.RSVP.Promise((resolve, reject) => {
this.makeRequest(this.serverTokenRefreshEndpoint, data, headers).then(response => {
Ember.run(() => {
const resToken = response[this.tokenPropertyName];
const resToken = Ember.get(response, this.tokenPropertyName);
const tokenData = this.getTokenData(resToken);
const expiresAt = tokenData[this.tokenExpireName];
const expiresAt = Ember.get(tokenData, this.tokenExpireName);
const tokenExpireData = {};

tokenExpireData[this.tokenExpireName] = expiresAt;
Expand Down

0 comments on commit a910d84

Please sign in to comment.