[js] move auth statics
This commit is contained in:
parent
2ae3003597
commit
86512320f0
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue