BrixCafe/firebase/auth.ts
2025-04-16 03:31:43 +01:00

26 lines
729 B
TypeScript

import { getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword } from "firebase/auth";
import { app } from "./config"; // ton fichier config Firebase
const auth = getAuth(app);
export const signIn = async (email: string, password: string) => {
try {
const userCredential = await signInWithEmailAndPassword(auth, email, password);
return { user: userCredential.user };
} catch (error: any) {
throw new Error(error.message);
}
};
export const signUp = async (email: string, password: string) => {
try {
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
return userCredential.user;
} catch (error: any) {
throw new Error(error.message);
}
};