Skip to content
This repository was archived by the owner on Apr 3, 2019. 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
40 changes: 0 additions & 40 deletions app/scripts/lib/app-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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())
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand Down
25 changes: 21 additions & 4 deletions app/scripts/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down