Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
fix(baseConfig): explain getExpirationDateFromResponse and ensure format
Browse files Browse the repository at this point in the history
  • Loading branch information
doktordirk committed Oct 14, 2016
1 parent ed1fed8 commit ee30ce4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions doc/baseConfig.md
Expand Up @@ -125,13 +125,13 @@ storage = 'localStorage';
storageKey = 'aurelia_authentication';
// full page reload if authorization changed in another tab (recommended to set it to 'true')
storageChangedReload = false;
// optional function to extract the expiration date. takes the server response as parameter
// optional function to extract the expiration date. Takes the server response as parameter and returns number of seconds! since 1 January 1970 00:00:00 UTC (Unix Epoch)
// eg (expires_in in sec): getExpirationDateFromResponse = serverResponse => new Date().getTime() + serverResponse.expires_in * 1000;
getExpirationDateFromResponse = null;
// optional function to extract the access token from the response. takes the server response as parameter
// optional function to extract the access token from the response. Takes the server response as parameter and returns a token
// eg: getAccessTokenFromResponse = serverResponse => serverResponse.data[0].access_token;
getAccessTokenFromResponse = null;
// optional function to extract the refresh token from the response. takes the server response as parameter
// optional function to extract the refresh token from the response. Takes the server response as parameter and returns a token
// eg: getRefreshTokenFromResponse = serverResponse => serverResponse.data[0].refresh_token;
getRefreshTokenFromResponse = null;

Expand Down
6 changes: 3 additions & 3 deletions src/authentication.js
Expand Up @@ -186,9 +186,9 @@ export class Authentication {
} catch (_) {} // eslint-disable-line no-empty

// get exp either with from jwt or with supplied function
this.exp = typeof this.config.getExpirationDateFromResponse === 'function'
? this.config.getExpirationDateFromResponse(response)
: (this.payload && parseInt(this.payload.exp, 10)) || NaN;
this.exp = parseInt((typeof this.config.getExpirationDateFromResponse === 'function'
? this.config.getExpirationDateFromResponse(response)
: this.payload && this.payload.exp), 10) || NaN;

this.responseAnalyzed = true;

Expand Down
10 changes: 5 additions & 5 deletions src/baseConfig.js
Expand Up @@ -151,22 +151,22 @@ export class BaseConfig {
storage = 'localStorage';
// The key used for storing the authentication response locally
storageKey = 'aurelia_authentication';
// full page reload if authorization changed in another tab (recommended to set it to 'true')
// full page reload if authorization changed in another tab (recommended to set it to 'true')
storageChangedReload = false;
// optional function to extract the expiration date. takes the server response as parameter
// optional function to extract the expiration date. Takes the server response as parameter and returns number of seconds! since 1 January 1970 00:00:00 UTC (Unix Epoch)
// eg (expires_in in sec): getExpirationDateFromResponse = serverResponse => new Date().getTime() + serverResponse.expires_in * 1000;
getExpirationDateFromResponse = null;
// optional function to extract the access token from the response. takes the server response as parameter
// optional function to extract the access token from the response. Takes the server response as parameter and returns a token
// eg: getAccessTokenFromResponse = serverResponse => serverResponse.data[0].access_token;
getAccessTokenFromResponse = null;
// optional function to extract the refresh token from the response. takes the server response as parameter
// optional function to extract the refresh token from the response. Takes the server response as parameter and returns a token
// eg: getRefreshTokenFromResponse = serverResponse => serverResponse.data[0].refresh_token;
getRefreshTokenFromResponse = null;

// List of value-converters to make global
globalValueConverters = ['authFilterValueConverter'];

//OAuth provider specific related configuration
//OAuth provider specific related configuration
// ============================================
providers = {
facebook: {
Expand Down

0 comments on commit ee30ce4

Please sign in to comment.