Fallback when user_profiles missing — return local demo profile
cgen-d54ed16ecf0843a1ba1e24976359c079
This commit is contained in:
parent
0716b6f5e9
commit
2c74312458
1 changed files with 19 additions and 2 deletions
|
|
@ -130,9 +130,26 @@ export const aethexUserService = {
|
|||
}
|
||||
|
||||
if (isTableMissing(error)) {
|
||||
throw new Error(
|
||||
'Supabase table "user_profiles" is missing. Please run the required migrations.',
|
||||
console.warn(
|
||||
'Supabase table "user_profiles" is missing. Falling back to local demo profile.',
|
||||
);
|
||||
const fallback: AethexUserProfile = {
|
||||
id: user.id,
|
||||
username: user.email?.split("@")[0] || `user_${Date.now()}`,
|
||||
full_name: user.email?.split("@")[0] || "user",
|
||||
email: user.email,
|
||||
user_type: "community_member" as any,
|
||||
experience_level: "beginner" as any,
|
||||
level: 1,
|
||||
total_xp: 0,
|
||||
loyalty_points: 0,
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
} as AethexUserProfile;
|
||||
try {
|
||||
localStorage.setItem(`demo_profile_${user.id}`, JSON.stringify(fallback));
|
||||
} catch {}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
throw error;
|
||||
|
|
|
|||
Loading…
Reference in a new issue