@@ -13,7 +13,6 @@ import {
1313import { useEffect , useState } from "react" ;
1414import { isAllowedEmail } from "../config" ;
1515
16- // Auth Hook
1716export function useAuth ( ) {
1817 const [ user , setUser ] = useState < User | null > ( null ) ;
1918 const [ loading , setLoading ] = useState ( true ) ;
@@ -29,22 +28,19 @@ export function useAuth() {
2928 return { user, loading } ;
3029}
3130
32- // Sign In
3331export const signIn = async ( email : string , pass : string ) => {
3432 if ( ! isAllowedEmail ( email ) ) {
3533 throw new Error ( "ACCESS_DENIED" ) ;
3634 }
3735 const userCredential = await signInWithEmailAndPassword ( auth , email , pass ) ;
3836
39- // Check if email is verified
4037 if ( ! userCredential . user . emailVerified ) {
4138 throw new Error ( "EMAIL_NOT_VERIFIED" ) ;
4239 }
4340
4441 return userCredential ;
4542} ;
4643
47- // Sign Up (for initial seeding or admin use)
4844export const signUp = async ( name : string , email : string , pass : string ) => {
4945
5046 if ( ! isAllowedEmail ( email ) ) {
@@ -57,25 +53,20 @@ export const signUp = async (name: string, email: string, pass: string) => {
5753 return userCredential ;
5854} ;
5955
60- // Sign Out
6156export const signOut = ( ) => firebaseSignOut ( auth ) ;
6257
63- // Check if email exists
6458export const checkEmailExists = async ( email : string ) : Promise < boolean > => {
6559 try {
6660 const methods = await fetchSignInMethodsForEmail ( auth , email ) ;
6761 return methods . length > 0 ;
6862 } catch ( error : any ) {
69- // If error code is auth/invalid-email, the email format is wrong
7063 if ( error . code === 'auth/invalid-email' ) {
7164 return false ;
7265 }
73- // For other errors, return false to be safe
7466 console . error ( "Error checking email existence:" , error ) ;
7567 return false ;
7668 }
7769} ;
7870
79- // Password Reset
8071export const resetPassword = ( email : string ) =>
8172 sendPasswordResetEmail ( auth , email ) ;
0 commit comments