BrixCafe/firebase/auth.ts
2025-04-23 03:41:33 +01:00

22 lines
670 B
TypeScript

// auth.ts
import { signInWithEmailAndPassword, createUserWithEmailAndPassword } from "firebase/auth";
import { auth } from "./config";
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);
}
};