add some comments and add text to log output
This commit is contained in:
parent
7046b23a27
commit
7f7487836c
@ -2,6 +2,10 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import { Alert, Button, View, Text, TextInput, TouchableWithoutFeedback, Keyboard } from "react-native";
|
import { Alert, Button, View, Text, TextInput, TouchableWithoutFeedback, Keyboard } from "react-native";
|
||||||
import auth, { FirebaseAuthTypes } from '@react-native-firebase/auth';
|
import auth, { FirebaseAuthTypes } from '@react-native-firebase/auth';
|
||||||
|
|
||||||
|
// This code is beginning of Auth Implementation - actual implementation will differ and involve more UI
|
||||||
|
// Does not have a restart or proper handling of code confirmation, should only be used for obtaining token/testing
|
||||||
|
// Currently working for Android builds, iOS has open issue #56
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
const [phoneNumber, setPhoneNumber] = useState<string>('');
|
const [phoneNumber, setPhoneNumber] = useState<string>('');
|
||||||
const [code, setCode] = useState<string>('');
|
const [code, setCode] = useState<string>('');
|
||||||
@ -9,14 +13,14 @@ export default function Login() {
|
|||||||
const [user, setUser] = useState(null);
|
const [user, setUser] = useState(null);
|
||||||
const [confirm, setConfirm] = useState<FirebaseAuthTypes.ConfirmationResult | null>(null);
|
const [confirm, setConfirm] = useState<FirebaseAuthTypes.ConfirmationResult | null>(null);
|
||||||
|
|
||||||
async function onAuthStateChanged(user) {
|
async function onAuthStateChanged(user: any) {
|
||||||
setUser(user);
|
setUser(user);
|
||||||
if (user) {
|
if (user) {
|
||||||
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
||||||
const token = await auth().currentUser?.getIdToken();
|
const token = await auth().currentUser?.getIdToken();
|
||||||
// To debug/check token & user return, use these logs
|
// To debug/check token & user return, use these logs
|
||||||
console.log(token) // token log
|
// console.log(token) // token log
|
||||||
console.log(user) // user log
|
// console.log(user) // user log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +83,10 @@ export default function Login() {
|
|||||||
onPress={() => !confirm ? signInWithPhoneNumber(phoneNumber) : confirmCode()}
|
onPress={() => !confirm ? signInWithPhoneNumber(phoneNumber) : confirmCode()}
|
||||||
/>
|
/>
|
||||||
{user && (
|
{user && (
|
||||||
<Text>{user?.user_id}</Text>
|
<>
|
||||||
|
<Text style={{ marginTop: 10 }}>Display name: {user?.displayName}</Text>
|
||||||
|
<Text>Phone number: {user?.phoneNumber}</Text>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</TouchableWithoutFeedback>
|
</TouchableWithoutFeedback>
|
||||||
|
Loading…
Reference in New Issue
Block a user