wip: token passed to headers, need to make hook for onAuthStateChanged

This commit is contained in:
Loewy
2024-02-05 23:58:39 -08:00
11 changed files with 107 additions and 45 deletions

View File

@@ -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()
}