Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ web:
providerData: false
tenant: false

application:
expand:
customData: false

# If the developer wants our integration to serve their Single Page
# Application (SPA) in response to HTML requests for our default routes,
# such as /login, then they will need to enable this feature and tell us
Expand Down
35 changes: 35 additions & 0 deletions lib/helpers/get-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';

/**
* @function
* @private
*
* @description
* Loads the application from a href, optionally expanding fields passed via the
* `expand` parameter.
*
* @param {String} appHref
* The HREF of the application to load.
* @param {Object} client
* The Stormpath client
* @param {Object} expand
* Definition of which objects to expand as an object of string-boolean pairs.
* @param {Function} callback
* The function to call when done. Called with {err, Application}
*/
module.exports = function getApplication(appHref, client, expand, callback) {
var appOptions = {};
var expandOn = [];

Object.keys(expand).forEach(function (field) {
if (expand[field]) {
expandOn.push(field);
}
});

if (expandOn) {
appOptions.expand = expandOn.join(',');
}

return client.getApplication(appHref, appOptions, callback);
};
3 changes: 2 additions & 1 deletion lib/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ module.exports = {
xsrfValidator: require('./xsrf-validator'),
revokeToken: require('./revoke-token'),
getFormViewModel: require('./get-form-view-model').default,
strippedAccountResponse: require('./stripped-account-response')
strippedAccountResponse: require('./stripped-account-response'),
getApplication: require('./get-application')
};
2 changes: 1 addition & 1 deletion lib/stormpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ module.exports.init = function (app, opts) {
router.all(web.oauth2.uri, bodyParser.form(), stormpathMiddleware, controllers.getToken);
}

client.getApplication(config.application.href, function (err, application) {
helpers.getApplication(config.application.href, client, web.application.expand, function (err, application) {
if (err) {
throw new Error('Cannot fetch application ' + config.application.href);
}
Expand Down