Update createInitialProfile to remove mock fallback
cgen-72d47237768349d1b223c597d8a4bd54
This commit is contained in:
parent
c6c2155413
commit
c12b79ac17
1 changed files with 4 additions and 48 deletions
|
|
@ -252,29 +252,8 @@ export const aethexUserService = {
|
|||
userId: string,
|
||||
profileData: Partial<AethexUserProfile>,
|
||||
): Promise<AethexUserProfile | null> {
|
||||
if (!isSupabaseConfigured) {
|
||||
const mock = await mockAuth.updateProfile(
|
||||
userId as any,
|
||||
{
|
||||
username: profileData.username || `user_${Date.now()}`,
|
||||
full_name: profileData.full_name,
|
||||
bio: profileData.bio,
|
||||
location: profileData.location,
|
||||
linkedin_url: profileData.linkedin_url as any,
|
||||
github_url: profileData.github_url as any,
|
||||
twitter_url: profileData.twitter_url as any,
|
||||
level: 1,
|
||||
total_xp: 0,
|
||||
} as any,
|
||||
);
|
||||
return {
|
||||
...(mock as any),
|
||||
onboarded: true,
|
||||
role: "member",
|
||||
loyalty_points: 0,
|
||||
} as any;
|
||||
}
|
||||
// Only insert fields that exist in the actual database schema
|
||||
ensureSupabase();
|
||||
|
||||
const { data, error } = await supabase
|
||||
.from("user_profiles")
|
||||
.insert({
|
||||
|
|
@ -299,37 +278,14 @@ export const aethexUserService = {
|
|||
.single();
|
||||
|
||||
if (error) {
|
||||
console.warn("Error creating profile, attempting mock fallback:", error);
|
||||
if (isTableMissing(error)) {
|
||||
const mock = await mockAuth.updateProfile(
|
||||
userId as any,
|
||||
{
|
||||
username: profileData.username || `user_${Date.now()}`,
|
||||
full_name: profileData.full_name,
|
||||
bio: profileData.bio,
|
||||
location: profileData.location,
|
||||
linkedin_url: profileData.linkedin_url as any,
|
||||
github_url: profileData.github_url as any,
|
||||
twitter_url: profileData.twitter_url as any,
|
||||
level: 1,
|
||||
total_xp: 0,
|
||||
} as any,
|
||||
throw new Error(
|
||||
"Supabase table \"user_profiles\" is missing. Please run the required migrations.",
|
||||
);
|
||||
|
||||
return {
|
||||
...(mock as any),
|
||||
onboarded: true,
|
||||
role: "member",
|
||||
loyalty_points: 0,
|
||||
} as any;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
try {
|
||||
await mockAuth.updateProfile(userId as any, data as any);
|
||||
} catch {}
|
||||
|
||||
return {
|
||||
...data,
|
||||
onboarded: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue