fenichelar/ember-simple-auth-token

Overriding Token Property Name No Longer Works

thegranddesign opened this issue · 5 comments

I think there's a typo where the configuration option was changed to tokenDataPropertyName but there are still references to tokenPropertyName here and because it's always null, the default is always used.

tokenPropertyName is still the correct config setting to use. tokenDataPropertyName is a different setting.

I just overwrote tokenPropertyName to token2 and it worked as expected.

@thegranddesign I'm going to close this, let me know if you are still experiencing issues.

Please explain how the readme states otherwise? From the readme:

tokenPropertyName: 'token', // Key in server response that contains the access token
tokenDataPropertyName: 'tokenData'; // Key in session to store token data

What are you attempting to do? If you are attempting to change the property in the server response that contains the token, use tokenPropertyName. If you are attempting to change the property in the session that contains the decoded token data, use tokenDataPropertyName.

@fenichelar Ah I see now. IMO the README is unclear. It would be better to just repeat the settings for each type. Additionally some alignment of the values would make things much more readable:

ENV['ember-simple-auth-token'] = {
  tokenDataPropertyName: 'tokenData'; // Key in session to store token data
  refreshAccessTokens: true, // Enables access token refreshing
  tokenExpirationInvalidateSession: true, // Enables session invalidation on token expiration
  serverTokenRefreshEndpoint: '/api/token-refresh/', // Server endpoint to send refresh request
  refreshTokenPropertyName: 'refresh_token', // Key in server response that contains the refresh token
  tokenExpireName: 'exp', // Field containing token expiration
  refreshLeeway: 0 // Amount of time to send refresh request before token expiration
};

versus

ENV['ember-simple-auth-token'] = {
  tokenDataPropertyName:            'tokenData',           // Key in session to store token data
  refreshAccessTokens:              true,                  // Enables access token refreshing
  tokenExpirationInvalidateSession: true,                  // Enables session invalidation on token expiration
  serverTokenRefreshEndpoint:       '/api/token-refresh/', // Server endpoint to send refresh request
  refreshTokenPropertyName:         'refresh_token',       // Key in server response that contains the refresh token
  tokenExpireName:                  'exp',                 // Field containing token expiration
  refreshLeeway:                    0                      // Amount of time to send refresh request before token expiration
};

Thanks for the response!