All 3 auth methods work & update public profile table as well

This commit is contained in:
2025-03-10 13:59:04 -05:00
parent 07bf94d393
commit f9fd5dafc5
6 changed files with 140 additions and 83 deletions

View File

@@ -4,6 +4,7 @@ import { supabase } from '@/lib/supabase';
import { ThemedView, ThemedText, ThemedTextButton, ThemedTextInput } from '@/components/theme';
import AppleSignInButton from '@/components/auth/AppleSignIniOS';
import AzureSignIn from './AzureSignIn';
import type { updateUser } from '@/constants/Types';
// Tells Supabase Auth to continuously refresh the session automatically if
// the app is in the foreground. When this is added, you will continue to receive
@@ -20,6 +21,7 @@ if (Platform.OS !== 'web') {
}
const Auth = () => {
const [full_name, setFullName] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [loading, setLoading] = useState(false);
@@ -50,11 +52,26 @@ const Auth = () => {
data: { session },
error,
} = await supabase.auth.signUp({
email: email,
password: password,
email,
password,
});
if (error) Alert.alert(error.message);
else if (!session) Alert.alert('Please check your inbox for email verification!');
else {
const { error: updateProfileError } = await supabase
.from('profiles')
.upsert({
id: session.user.id,
full_name,
email,
provider: 'email',
updated_at: new Date(),
});
if (updateProfileError) {
Alert.alert('Error updating profile:', updateProfileError.message);
console.error('Error updating profile:', updateProfileError.message);
}
}
setLoading(false);
};
@@ -67,6 +84,15 @@ const Auth = () => {
</ThemedText>
</ThemedView>
<ThemedView style={styles.verticallySpaced}>
<ThemedTextInput
fontSize={24}
onChangeText={(text) => setFullName(text)}
value={full_name}
placeholder='Full Name'
/>
</ThemedView>
<ThemedView style={[styles.verticallySpaced]}>
<ThemedTextInput
fontSize={24}