diff --git a/lib/flow.js b/lib/flow.js index 406341af..ec6ada1f 100644 --- a/lib/flow.js +++ b/lib/flow.js @@ -7,7 +7,7 @@ declare module 'react-native' { declare type AuthResultType = { authenticated: boolean, user: Object|null -}; +} | null; declare type CredentialType = { provider: string, diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index f8f6fe4c..962ba072 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -3,7 +3,7 @@ import { NativeModules, NativeEventEmitter } from 'react-native'; import User from './user'; import { Base } from './../base'; -import EmailAuthProvider from './Email'; +import EmailAuthProvider from './providers/Email'; const FirebaseAuth = NativeModules.RNFirebaseAuth; const FirebaseAuthEvt = new NativeEventEmitter(FirebaseAuth); @@ -36,7 +36,7 @@ export default class Auth extends Base { * @param emit * @private */ - _onAuthStateChanged(auth: AuthResultType, emit: Boolean = true) { + _onAuthStateChanged(auth: AuthResultType, emit: boolean = true) { this._authResult = auth; this.authenticated = auth ? auth.authenticated || false : false; if (auth && auth.user && !this._user) this._user = new User(this, auth); @@ -67,7 +67,7 @@ export default class Auth extends Base { return promise.then((result) => { if (!result) return this._onAuthStateChanged(null, false); if (result.user) return this._onAuthStateChanged(result, false); - if (result.uid) return this._onAuthStateChanged({ user: result }, false); + if (result.uid) return this._onAuthStateChanged({ authenticated: true, user: result }, false); return result; }); } diff --git a/lib/modules/auth/Email.js b/lib/modules/auth/providers/Email.js similarity index 100% rename from lib/modules/auth/Email.js rename to lib/modules/auth/providers/Email.js