wip: token passed to headers, need to make hook for onAuthStateChanged
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import auth, { FirebaseAuthTypes } from '@react-native-firebase/auth';
|
||||
import { Alert } from 'react-native';
|
||||
|
||||
@@ -23,6 +24,8 @@ export const confirmCode = async (confirm: FirebaseAuthTypes.ConfirmationResult,
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: eslint not detecting ts?
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
export const onAuthStateChanged = (callback: (user: FirebaseAuthTypes.User | null) => void) => {
|
||||
return auth().onAuthStateChanged(callback);
|
||||
};
|
||||
@@ -37,12 +40,6 @@ export const getCurrentUserToken = async (): Promise<string | null> => {
|
||||
};
|
||||
|
||||
export const signOut = async (): Promise<void> => {
|
||||
try {
|
||||
auth().signOut()
|
||||
// tie in to AppNav
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
// toggle appnav state regardless
|
||||
// Handle sign out error - have to look into best way to do this - asyncstorage?
|
||||
}
|
||||
await AsyncStorage.removeItem('token');
|
||||
auth().signOut()
|
||||
}
|
Reference in New Issue
Block a user