Cleaned up auth. Ensured everything is necessary
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user