From 86512320f0694f847cac5e91c84cf4b7b7bcd3cb Mon Sep 17 00:00:00 2001 From: Salakar Date: Mon, 27 Mar 2017 19:11:26 +0100 Subject: [PATCH] [js] move auth statics --- lib/firebase.js | 10 +++++----- lib/modules/auth/index.js | 15 ++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/firebase.js b/lib/firebase.js index e8a56364..567df61f 100644 --- a/lib/firebase.js +++ b/lib/firebase.js @@ -8,7 +8,7 @@ import Log from './utils/log'; import { isObject } from './utils'; // modules -import Auth from './modules/auth'; +import Auth, { statics as AuthStatics } from './modules/auth'; import Storage, { statics as StorageStatics } from './modules/storage'; import Database, { statics as DatabaseStatics } from './modules/database'; import Messaging from './modules/messaging'; @@ -54,8 +54,12 @@ export default class Firebase { throw new Error(`Google Play Services is required to run this application but no valid installation was found (Code ${this.googleApiAvailability.status}).`); } + this.auth = this._staticsOrInstance('auth', StorageStatics, Auth); this.storage = this._staticsOrInstance('storage', StorageStatics, Storage); this.database = this._staticsOrInstance('database', DatabaseStatics, Database); + + // init auth to stat listeners + this.auth(); } /** @@ -81,10 +85,6 @@ export default class Firebase { return instances[name]; } - auth() { - return this._auth; - } - analytics() { if (!this._analytics) { this._analytics = new Analytics(this); diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index 3264f3d3..bd00d445 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -25,13 +25,6 @@ export default class Auth extends Base { this._authResult = null; this.authenticated = false; - // attach auth providers - this.EmailAuthProvider = EmailAuthProvider; - this.GoogleAuthProvider = GoogleAuthProvider; - this.FacebookAuthProvider = FacebookAuthProvider; - this.TwitterAuthProvider = TwitterAuthProvider; - this.GithubAuthProvider = GithubAuthProvider; - // start listening immediately for auth changes FirebaseAuthEvt.addListener('onAuthStateChanged', this._onAuthStateChanged.bind(this)); FirebaseAuth.addAuthStateListener(); @@ -175,3 +168,11 @@ export default class Auth extends Base { return 'firebase:auth'; } } + +export const statics = { + GoogleAuthProvider, + EmailAuthProvider, + FacebookAuthProvider, + TwitterAuthProvider, + GithubAuthProvider, +};