fix prettier conflicts
This commit is contained in:
@@ -1,45 +1,53 @@
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import auth, { FirebaseAuthTypes } from '@react-native-firebase/auth';
|
||||
import { Alert } from 'react-native';
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import auth, { FirebaseAuthTypes } from "@react-native-firebase/auth";
|
||||
import { Alert } from "react-native";
|
||||
|
||||
export const handleSignInWithPhoneNumber = async (phoneNumber: string): Promise<FirebaseAuthTypes.ConfirmationResult | undefined> => {
|
||||
if (!phoneNumber) {
|
||||
Alert.alert("Please enter a valid phone number with a country code");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
|
||||
return confirmation;
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
Alert.alert("There was an error. Make sure you are using a country code (ex: +1 for US)");
|
||||
}
|
||||
export const handleSignInWithPhoneNumber = async (
|
||||
phoneNumber: string,
|
||||
): Promise<FirebaseAuthTypes.ConfirmationResult | undefined> => {
|
||||
if (!phoneNumber) {
|
||||
Alert.alert("Please enter a valid phone number with a country code");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
|
||||
return confirmation;
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
Alert.alert(
|
||||
"There was an error. Make sure you are using a country code (ex: +1 for US)",
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const confirmCode = async (confirm: FirebaseAuthTypes.ConfirmationResult, code: string): Promise<void> => {
|
||||
try {
|
||||
await confirm.confirm(code);
|
||||
} catch {
|
||||
Alert.alert("Invalid code, please try again.");
|
||||
}
|
||||
export const confirmCode = async (
|
||||
confirm: FirebaseAuthTypes.ConfirmationResult,
|
||||
code: string,
|
||||
): Promise<void> => {
|
||||
try {
|
||||
await confirm.confirm(code);
|
||||
} catch {
|
||||
Alert.alert("Invalid code, please try again.");
|
||||
}
|
||||
};
|
||||
|
||||
// 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);
|
||||
export const onAuthStateChanged = (
|
||||
// TODO: eslint not detecting ts?
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
callback: (user: FirebaseAuthTypes.User | null) => void,
|
||||
) => {
|
||||
return auth().onAuthStateChanged(callback);
|
||||
};
|
||||
|
||||
|
||||
export const getCurrentUserToken = async (): Promise<string | null> => {
|
||||
const user = auth().currentUser;
|
||||
if (user) {
|
||||
return await user.getIdToken();
|
||||
}
|
||||
return null;
|
||||
const user = auth().currentUser;
|
||||
if (user) {
|
||||
return await user.getIdToken();
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export const handleSignOut = async (): Promise<void> => {
|
||||
await AsyncStorage.removeItem('token');
|
||||
await auth().signOut()
|
||||
}
|
||||
await AsyncStorage.removeItem("token");
|
||||
await auth().signOut();
|
||||
};
|
||||
|
@@ -1,15 +1,15 @@
|
||||
import {
|
||||
handleSignInWithPhoneNumber,
|
||||
confirmCode,
|
||||
onAuthStateChanged,
|
||||
getCurrentUserToken,
|
||||
handleSignOut
|
||||
} from './firebase-auth'
|
||||
confirmCode,
|
||||
getCurrentUserToken,
|
||||
handleSignInWithPhoneNumber,
|
||||
handleSignOut,
|
||||
onAuthStateChanged,
|
||||
} from "./firebase-auth";
|
||||
|
||||
export {
|
||||
handleSignInWithPhoneNumber,
|
||||
confirmCode,
|
||||
onAuthStateChanged,
|
||||
getCurrentUserToken,
|
||||
handleSignOut
|
||||
}
|
||||
confirmCode,
|
||||
getCurrentUserToken,
|
||||
handleSignInWithPhoneNumber,
|
||||
handleSignOut,
|
||||
onAuthStateChanged,
|
||||
};
|
||||
|
Reference in New Issue
Block a user