Update updateProfile to remove mock fallback
cgen-a8151420d19b459c8637eca0dd941c84
This commit is contained in:
parent
b5a65d7f24
commit
c6c2155413
1 changed files with 9 additions and 15 deletions
|
|
@ -213,10 +213,8 @@ export const aethexUserService = {
|
|||
userId: string,
|
||||
updates: Partial<AethexUserProfile>,
|
||||
): Promise<AethexUserProfile | null> {
|
||||
if (!isSupabaseConfigured) {
|
||||
const mock = await mockAuth.updateProfile(userId as any, updates as any);
|
||||
return mock as unknown as AethexUserProfile;
|
||||
}
|
||||
ensureSupabase();
|
||||
|
||||
const { data, error } = await supabase
|
||||
.from("user_profiles")
|
||||
.update(updates)
|
||||
|
|
@ -225,13 +223,6 @@ export const aethexUserService = {
|
|||
.single();
|
||||
|
||||
if (error) {
|
||||
if (isTableMissing(error)) {
|
||||
const mock = await mockAuth.updateProfile(
|
||||
userId as any,
|
||||
updates as any,
|
||||
);
|
||||
return mock as unknown as AethexUserProfile;
|
||||
}
|
||||
if ((error as any)?.code === "PGRST116") {
|
||||
const { data: upserted, error: upsertError } = await supabase
|
||||
.from("user_profiles")
|
||||
|
|
@ -244,13 +235,16 @@ export const aethexUserService = {
|
|||
if (upsertError) throw upsertError;
|
||||
return upserted as AethexUserProfile;
|
||||
}
|
||||
|
||||
if (isTableMissing(error)) {
|
||||
throw new Error(
|
||||
"Supabase table \"user_profiles\" is missing. Please run the required migrations.",
|
||||
);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
try {
|
||||
await mockAuth.updateProfile(userId as any, updates as any);
|
||||
} catch {}
|
||||
|
||||
return data as AethexUserProfile;
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue