diff --git a/app/scripts/lib/app-start.js b/app/scripts/lib/app-start.js index 82c0fc39eb..41b308d41e 100644 --- a/app/scripts/lib/app-start.js +++ b/app/scripts/lib/app-start.js @@ -27,18 +27,14 @@ import Constants from './constants'; import Environment from './environment'; import ErrorUtils from './error-utils'; import FormPrefill from '../models/form-prefill'; -import FxaClient from './fxa-client'; import HeightObserver from './height-observer'; import IframeChannel from './channels/iframe'; import InterTabChannel from './channels/inter-tab'; -import MarketingEmailClient from './marketing-email-client'; import Metrics from './metrics'; import Notifier from './channels/notifier'; import NullChannel from './channels/null'; -import OAuthClient from './oauth-client'; import OAuthRelier from '../models/reliers/oauth'; import p from './promise'; -import ProfileClient from './profile-client'; import RefreshObserver from '../models/refresh-observer'; import Relier from '../models/reliers/relier'; import Router from './router'; @@ -108,15 +104,11 @@ Start.prototype = { .then(() => this.initializeInterTabChannel()) .then(() => this.initializeExperimentGroupingRules()) .then(() => this.initializeErrorMetrics()) - .then(() => this.initializeOAuthClient()) // both the metrics and router depend on the language // fetched from config. .then(() => this.initializeRelier()) // iframe channel depends on the relier. .then(() => this.initializeIframeChannel()) - // fxaClient depends on the relier and - // inter tab communication. - .then(() => this.initializeFxaClient()) // depends on nothing .then(() => this.initializeNotificationChannel()) // depends on iframeChannel and interTabChannel, web channel @@ -125,10 +117,6 @@ Start.prototype = { .then(() => this.initializeMetrics()) // assertionLibrary depends on fxaClient .then(() => this.initializeAssertionLibrary()) - // profileClient depends on fxaClient and assertionLibrary - .then(() => this.initializeProfileClient()) - // marketingEmailClient depends on config - .then(() => this.initializeMarketingEmailClient()) // broker relies on the relier, fxaClient, // assertionLibrary, and metrics .then(() => this.initializeAuthenticationBroker()) @@ -229,25 +217,6 @@ Start.prototype = { this._formPrefill = new FormPrefill(); }, - initializeOAuthClient () { - this._oAuthClient = new OAuthClient({ - oAuthUrl: this._config.oAuthUrl - }); - }, - - initializeProfileClient () { - this._profileClient = new ProfileClient({ - profileUrl: this._config.profileUrl - }); - }, - - initializeMarketingEmailClient () { - this._marketingEmailClient = new MarketingEmailClient({ - baseUrl: this._config.marketingEmailServerUrl, - preferencesUrl: this._config.marketingEmailPreferencesUrl - }); - }, - initializeRelier () { if (! this._relier) { let relier; @@ -381,15 +350,6 @@ Start.prototype = { } }, - initializeFxaClient () { - if (! this._fxaClient) { - this._fxaClient = new FxaClient({ - authServerUrl: this._config.authServerUrl, - interTabChannel: this._interTabChannel - }); - } - }, - initializeUser () { if (! this._user) { const user = this._user = new User({ diff --git a/app/scripts/models/user.js b/app/scripts/models/user.js index 0095528c15..38d2f05c6f 100644 --- a/app/scripts/models/user.js +++ b/app/scripts/models/user.js @@ -21,14 +21,31 @@ const ResumeTokenMixin = require('./mixins/resume-token'); const UrlMixin = require('./mixins/url'); const Storage = require('../lib/storage'); const vat = require('../lib/vat'); +const ProfileClient = require('../lib/profile-client'); +const MarketingEmailClient = require('../lib/marketing-email-client'); +const OAuthClient = require('../lib/oauth-client'); +const InterTabChannel = require('../lib/channels/inter-tab'); +const FxaClient = require('../lib/fxa-client'); var User = Backbone.Model.extend({ initialize (options = {}) { + this._config = options.config; + this._interTabChannel = new InterTabChannel(); this._oAuthClientId = options.oAuthClientId; - this._oAuthClient = options.oAuthClient; - this._profileClient = options.profileClient; - this._fxaClient = options.fxaClient; - this._marketingEmailClient = options.marketingEmailClient; + this._oAuthClient = new OAuthClient({ + oAuthUrl: this._config.oAuthUrl + }); + this._profileClient = new ProfileClient({ + profileUrl: this._config.profileUrl + }); + this._fxaClient = new FxaClient({ + authServerUrl: this._config.authServerUrl, + interTabChannel: this._interTabChannel + }); + this._marketingEmailClient = new MarketingEmailClient({ + baseUrl: this._config.marketingEmailServerUrl, + preferencesUrl: this._config.marketingEmailPreferencesUrl + }); this._metrics = options.metrics; this._assertion = options.assertion; this._notifier = options.notifier;