[js] misc flow fixes in auth
This commit is contained in:
parent
83e5d1f3d0
commit
9d520c4693
@ -7,7 +7,7 @@ declare module 'react-native' {
|
|||||||
declare type AuthResultType = {
|
declare type AuthResultType = {
|
||||||
authenticated: boolean,
|
authenticated: boolean,
|
||||||
user: Object|null
|
user: Object|null
|
||||||
};
|
} | null;
|
||||||
|
|
||||||
declare type CredentialType = {
|
declare type CredentialType = {
|
||||||
provider: string,
|
provider: string,
|
||||||
|
@ -3,7 +3,7 @@ import { NativeModules, NativeEventEmitter } from 'react-native';
|
|||||||
|
|
||||||
import User from './user';
|
import User from './user';
|
||||||
import { Base } from './../base';
|
import { Base } from './../base';
|
||||||
import EmailAuthProvider from './Email';
|
import EmailAuthProvider from './providers/Email';
|
||||||
|
|
||||||
const FirebaseAuth = NativeModules.RNFirebaseAuth;
|
const FirebaseAuth = NativeModules.RNFirebaseAuth;
|
||||||
const FirebaseAuthEvt = new NativeEventEmitter(FirebaseAuth);
|
const FirebaseAuthEvt = new NativeEventEmitter(FirebaseAuth);
|
||||||
@ -36,7 +36,7 @@ export default class Auth extends Base {
|
|||||||
* @param emit
|
* @param emit
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onAuthStateChanged(auth: AuthResultType, emit: Boolean = true) {
|
_onAuthStateChanged(auth: AuthResultType, emit: boolean = true) {
|
||||||
this._authResult = auth;
|
this._authResult = auth;
|
||||||
this.authenticated = auth ? auth.authenticated || false : false;
|
this.authenticated = auth ? auth.authenticated || false : false;
|
||||||
if (auth && auth.user && !this._user) this._user = new User(this, auth);
|
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) => {
|
return promise.then((result) => {
|
||||||
if (!result) return this._onAuthStateChanged(null, false);
|
if (!result) return this._onAuthStateChanged(null, false);
|
||||||
if (result.user) return this._onAuthStateChanged(result, 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;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user