Cleaned up auth. Ensured everything is necessary

This commit is contained in:
2025-03-11 10:05:31 -05:00
parent 6c0a275ee0
commit 86d1df3558
6 changed files with 99 additions and 62 deletions

View File

@ -30,6 +30,7 @@ const AppleSignInButton = () => {
credential.fullName && credential.fullName.givenName && credential.fullName.familyName
? `${credential.fullName.givenName} ${credential.fullName.familyName}`
: null;
const {
error,
data: { user, session },
@ -41,26 +42,25 @@ const AppleSignInButton = () => {
if (!error && session) {
if (email) {
const data: updateUser = {
id: session?.user.id,
updated_at: new Date(),
email,
full_name: full_name ?? '',
provider: 'apple',
};
const { error: authUpdateError } = await supabase.auth.updateUser({
data,
});
if (authUpdateError)
Alert.alert('Error updating auth info:', authUpdateError.message);
const { error: updateError } = await supabase
const { error: updateError } = await supabase.auth.updateUser({ data });
if (updateError) Alert.alert('Error updating auth info:', updateError.message);
const { error: updateProfileError } = await supabase
.from('profiles')
.upsert({
id: session.user.id,
full_name,
email,
provider: 'apple',
id: session?.user.id ?? '',
updated_at: new Date(),
});
if (updateError) {
console.error('Error updating user metadata:', updateError);
}
email: email ?? '',
full_name: full_name ?? '',
provider: 'apple',
});
if (updateProfileError)
Alert.alert('Error updating profile:', updateProfileError.message);
}
}
} else {