UNPKG

gpii-universal

Version:

Cross platform, core components of the GPII personalization infrastructure.

72 lines (62 loc) 2.66 kB
/** * GPII Untrusted Local FlowManager * * Copyright 2015-2018 OCAD University * * Licensed under the New BSD license. You may not use this file except in * compliance with this License. * * You may obtain a copy of the License at * https://github.com/GPII/universal/blob/master/LICENSE.txt */ "use strict"; var fluid = require("infusion"), gpii = fluid.registerNamespace("gpii"); require("accessRequester"); fluid.require("%gpii-universal/gpii/node_modules/gpii-oauth2/gpii-oauth2-utilities/src/OAuth2Utilities.js"); // The Untrusted or Hybrid (Local) FlowManager is a Local FlowManager which defers to the cloud for the matchMaking // and Preferences fetch process. The architectural goal of the untrusted FlowManager is that the unfiltered // user preferences never reach the local device. Therefore the userLogon stages of the "gpii.flowManager.matchMaking" // are all abridged, and instead we simply receive a final settings payload from a cloudBased flowManager which are // then directly applied to the local device. // Described at https://issues.gpii.net/browse/GPII-1224 // Overrides request handlers in "gpii.flowManager.local" fluid.defaults("gpii.flowManager.untrusted", { // Distribute the grade to handle user logon requests. distributeOptions: { "lifecycleManager.loginRequestHandler": { record: "gpii.lifecycleManager.untrusted.stateChangeHandler", target: "{that gpii.lifecycleManager.loginRequest}.options.gradeNames" } }, components: { settingsDataSource: { type: "gpii.flowManager.settingsDataSource" // cloudURL: distributed down from, e.g., gpii.flowManager.untrusted.config.development } }, invokers: { setSettings: { func: "{that}.settingsDataSource.set", args: ["{arguments}.0", "{arguments}.1"] } }, listeners: { "preferencesSavedSuccess.log": { listener: "fluid.log", args: ["FlowManager: updated preferences have been saved to the cloud"] }, "preferencesSavedError.reportSaveError": { listener: "gpii.flowManager.untrusted.reportSaveError", args: ["{that}.userErrors.events.userError", "{arguments}.0"] } } }); gpii.flowManager.untrusted.reportSaveError = function (userErrorEvent, error) { fluid.log("The save of preferences to the cloud fails with the error: ", error); userErrorEvent.fire({ isError: true, messageKey: gpii.userErrors.isConnectionError(error.code) ? "NoConnection" : "SaveToCloudFail", originalError: error }); };