auth with handler

This commit is contained in:
tuanvu
2025-12-14 01:58:02 +01:00
parent 1f698076df
commit 0de6462c31
3 changed files with 65 additions and 50 deletions

View File

@@ -1,16 +1,11 @@
import { ThemedText } from "@/components/theme/themed-text";
import { ThemedTextInput } from "@/components/theme/themed-textinput";
import { ThemedView } from "@/components/theme/themed-view";
import { router } from "expo-router";
import {
signInWithEmailAndPassword
} from "firebase/auth";
import { signInWithEmailAndPassword } from "firebase/auth";
import React, { useState } from "react";
import { Button, StyleSheet, View } from "react-native";
import { auth } from "../../firebase_config";
const DEFAULT_ROLE = "resp";
const LoginScreen: React.FC = () => {
const [email, setEmail] = useState<string>("");
const [password, setPassword] = useState<string>("");
@@ -18,21 +13,11 @@ const LoginScreen: React.FC = () => {
const handleLogin = async () => {
try {
await signInWithEmailAndPassword(auth, email, password);
router.replace("/(tabs)");
} catch (error: any) {
alert(error.message);
}
};
/*const handleRegister = async () => {
try {
await createUserWithEmailAndPassword(auth, email, password);
router.replace("/(tabs)");
} catch (error: any) {
alert(error.message);
}
}; */
return (
<ThemedView lvl={1} style={styles.container}>
<ThemedText style={styles.title}>Se connecter</ThemedText>
@@ -45,7 +30,6 @@ const LoginScreen: React.FC = () => {
value={email}
onChangeText={setEmail}
autoCapitalize="none"
/>
<ThemedTextInput
lvl = {2}
@@ -59,7 +43,6 @@ const LoginScreen: React.FC = () => {
/>
<Button title="Se connecter" onPress={handleLogin} />
<View style={{ height: 10 }} />
{/* <Button title="S'inscrire" onPress={handleRegister} /> */}
</ThemedView>
);
};
@@ -76,7 +59,6 @@ const styles = StyleSheet.create({
},
input: {
borderWidth: 1,
//borderColor: "#ccc",
borderRadius: 8,
padding: 10,
marginBottom: 10,