Skip to content

Commit 298b7d9

Browse files
feat: attempt fix
1 parent de175be commit 298b7d9

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

packages/mobile/app/(auth)/sign-in.tsx

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ export default function SignInScreen() {
3838
setLoading(true);
3939
console.log('[SignIn] Attempting sign in with email');
4040

41-
// Create a sign in attempt
41+
if (!isLoaded || !signIn) {
42+
console.error('[SignIn] Clerk not loaded or signIn unavailable');
43+
Alert.alert('Error', 'Sign in service is not ready. Please try again.');
44+
setLoading(false);
45+
return;
46+
}
47+
4248
const result = await signIn.create({
4349
identifier: email,
4450
password,
@@ -49,19 +55,33 @@ export default function SignInScreen() {
4955
if (result.status === 'complete') {
5056
console.log('[SignIn] Sign in complete, activating session');
5157

52-
// Ensure we persist the session by setting it active
58+
if (!setSignInActive) {
59+
console.error('[SignIn] setSignInActive is unavailable');
60+
Alert.alert('Error', 'Could not activate session. Please try again.');
61+
setLoading(false);
62+
return;
63+
}
5364
await setSignInActive({ session: result.createdSessionId });
5465
console.log('[SignIn] Session activated successfully');
5566

56-
// Navigate to main app
5767
router.replace('/(tabs)');
5868
} else {
5969
console.log('[SignIn] Sign in requires additional steps:', result.status);
6070
// Handle additional verification if needed
6171
}
62-
} catch (err: any) {
72+
} catch (err: unknown) {
6373
console.error('[SignIn] Sign in error:', err);
64-
Alert.alert('Error', err.errors?.[0]?.message || 'Failed to sign in');
74+
// More generic error checking for Clerk
75+
let errorMessage = 'Failed to sign in. Please check your credentials.';
76+
if (typeof err === 'object' && err !== null && 'errors' in err) {
77+
const clerkError = err as { errors: { message: string }[] };
78+
if (Array.isArray(clerkError.errors) && clerkError.errors.length > 0 && clerkError.errors[0].message) {
79+
errorMessage = clerkError.errors[0].message;
80+
}
81+
} else if (err instanceof Error) {
82+
errorMessage = err.message; // Fallback to general error message
83+
}
84+
Alert.alert('Error', errorMessage);
6585
} finally {
6686
setLoading(false);
6787
}
@@ -185,10 +205,8 @@ export default function SignInScreen() {
185205
style={[styles.button, styles.appleButton]}
186206
onPress={onSignInWithApple}
187207
>
188-
<View style={styles.appleLogoContainer}>
189-
<Ionicons name="logo-apple" size={24} color="#FFFFFF" />
190-
</View>
191-
<Text style={[styles.buttonText, styles.appleButtonText]}>
208+
<Ionicons name="logo-apple" size={24} color="#000000" />
209+
<Text style={styles.buttonText}>
192210
Continue with Apple
193211
</Text>
194212
</TouchableOpacity>
@@ -306,20 +324,22 @@ const styles = StyleSheet.create({
306324
borderColor: '#ddd',
307325
},
308326
appleButton: {
309-
backgroundColor: '#000',
310-
borderColor: '#000',
327+
backgroundColor: '#fff',
328+
borderColor: '#ddd',
311329
},
312330
appleLogoContainer: {
313-
justifyContent: 'center',
314-
alignItems: 'center',
331+
// Remove this style - no longer needed
332+
// justifyContent: 'center',
333+
// alignItems: 'center',
315334
},
316335
buttonText: {
317336
fontSize: 16,
318337
fontWeight: '600',
319338
color: '#1a1a1a',
320339
},
321340
appleButtonText: {
322-
color: '#fff',
341+
// Remove this style - using buttonText now
342+
// color: '#fff',
323343
},
324344
divider: {
325345
flexDirection: 'row',

0 commit comments

Comments
 (0)