diff --git a/components/auth/AppleSignIn.tsx b/components/auth/AppleSignIn.tsx index eb2597b..386e36f 100644 --- a/components/auth/AppleSignIn.tsx +++ b/components/auth/AppleSignIn.tsx @@ -27,7 +27,7 @@ const AppleSignIn: React.FC = ({ const handleAppleSignIn = async () => { try { onSignInStart?.(); - + // Get credentials from Apple const credential = await AppleAuthentication.signInAsync({ requestedScopes: [ @@ -35,36 +35,36 @@ const AppleSignIn: React.FC = ({ AppleAuthentication.AppleAuthenticationScope.EMAIL, ], }); - + if (!credential.email) { throw new Error('Email is required for Apple Sign In'); } - + // Extract user information const { email, fullName, user: appleUserId } = credential; - + // Create a name from the fullName object if available let name = null; if (fullName?.givenName || fullName?.familyName) { name = `${fullName?.givenName || ''} ${fullName?.familyName || ''}`.trim(); } - + // Create a deterministic password based on the Apple user ID // This way the user can sign in again with the same password const password = `Apple-${appleUserId.substring(0, 16)}`; - + // First try to sign in (in case the user already exists) const { data: signInData, error: signInError } = await supabase.auth.signInWithPassword({ email, password, }); - + if (!signInError && signInData?.user) { // User exists and signed in successfully onSignInComplete?.(); return; } - + // If sign-in failed, create a new user const { data: signUpData, error: signUpError } = await supabase.auth.signUp({ email, @@ -72,26 +72,25 @@ const AppleSignIn: React.FC = ({ options: { data: { full_name: name, - } - } + }, + }, }); - + if (signUpError) { throw signUpError; } - + // User created successfully onSignInComplete?.(); - } catch (error) { console.error('Apple sign in error:', error); - + if (error.code === 'ERR_REQUEST_CANCELED') { console.log('Sign in was canceled'); } else { Alert.alert( 'Sign in error', - 'An error occurred while signing in with Apple. Please try again.' + 'An error occurred while signing in with Apple. Please try again.', ); onSignInError?.(error); } diff --git a/components/auth/Login.tsx b/components/auth/Login.tsx index 1aa80bd..e3e3297 100644 --- a/components/auth/Login.tsx +++ b/components/auth/Login.tsx @@ -22,7 +22,7 @@ const LoginPage = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); - + // Set up auto-refreshing for web useEffect(() => { if (Platform.OS === 'web') { @@ -32,7 +32,7 @@ const LoginPage = () => { }; } }, []); - + const signInWithEmail = async () => { setLoading(true); const { error } = await supabase.auth.signInWithPassword({ @@ -42,7 +42,7 @@ const LoginPage = () => { if (error) Alert.alert(error.message); setLoading(false); }; - + const signUpWithEmail = async () => { setLoading(true); const { @@ -56,7 +56,7 @@ const LoginPage = () => { else if (!session) Alert.alert('Please check your inbox for email verification!'); setLoading(false); }; - + return ( @@ -65,7 +65,7 @@ const LoginPage = () => { Tech Tracker - + { placeholder='email@address.com' /> - + { placeholder='Password' /> - + { fontSize={24} /> - + { fontSize={24} /> - + {/* Apple Sign In - Only shows on iOS */} - setLoading(true)} onSignInComplete={() => setLoading(false)} onSignInError={() => setLoading(false)} diff --git a/components/theme/inputs/ThemedTextInput.tsx b/components/theme/inputs/ThemedTextInput.tsx index 30cdce8..3a0c5c2 100644 --- a/components/theme/inputs/ThemedTextInput.tsx +++ b/components/theme/inputs/ThemedTextInput.tsx @@ -31,8 +31,9 @@ const ThemedTextInput: React.FC = ({ { width, height, - borderColor: Colors[scheme].accent }, - containerStyle, + borderColor: Colors[scheme].accent, + }, + containerStyle, ]} >