@@ -3,6 +3,7 @@ import { auth } from './firebase';
33import {
44 createUserWithEmailAndPassword ,
55 signInWithEmailAndPassword ,
6+ signInAnonymously ,
67} from 'firebase/auth' ;
78
89export default function AuthModal ( ) {
@@ -17,36 +18,38 @@ export default function AuthModal() {
1718 e . preventDefault ( ) ;
1819 setError ( '' ) ;
1920
20- if ( mode === 'signup' && password !== confirm ) {
21+ const targetEmail = email . trim ( ) . toLowerCase ( ) ;
22+ const targetPass = password . trim ( ) ;
23+
24+ if ( mode === 'signup' && targetPass !== confirm ) {
2125 setError ( 'Passwords do not match.' ) ;
2226 return ;
2327 }
24- if ( password . length < 6 ) {
28+ if ( targetPass . length < 6 ) {
2529 setError ( 'Password must be at least 6 characters.' ) ;
2630 return ;
2731 }
2832
2933 setLoading ( true ) ;
3034 try {
3135 if ( mode === 'signup' ) {
32- await createUserWithEmailAndPassword ( auth , email , password ) ;
36+ await createUserWithEmailAndPassword ( auth , targetEmail , targetPass ) ;
3337 } else {
3438 // Special bypass for Apple Reviewer
35- if ( email . toLowerCase ( ) === 'tester@test.com' && password === 'password' ) {
39+ if ( targetEmail === 'tester@test.com' && targetPass === 'password' ) {
3640 try {
37- await signInWithEmailAndPassword ( auth , email , password ) ;
41+ await signInWithEmailAndPassword ( auth , targetEmail , targetPass ) ;
3842 } catch ( e ) {
3943 // If account doesn't exist, create it on the fly
4044 try {
41- await createUserWithEmailAndPassword ( auth , email , password ) ;
45+ await createUserWithEmailAndPassword ( auth , targetEmail , targetPass ) ;
4246 } catch ( e2 ) {
4347 // Absolute fallback to anonymous if creation fails
44- const { signInAnonymously } = await import ( 'firebase/auth' ) ;
4548 await signInAnonymously ( auth ) ;
4649 }
4750 }
4851 } else {
49- await signInWithEmailAndPassword ( auth , email , password ) ;
52+ await signInWithEmailAndPassword ( auth , targetEmail , targetPass ) ;
5053 }
5154 }
5255 } catch ( err ) {
0 commit comments