refactor: remove isPro from database schema (#2050)
Browse files* refactor: remove isPro from database schema
- Remove isPro field from User type
- Remove isPro parsing from OAuth login
- Remove isPro from user API response
- isPro is now fetched purely client-side from HuggingFace public API
* fix: keep isPro as null on fetch error to avoid showing wrong badge
src/lib/server/api/routes/groups/user.ts
CHANGED
|
@@ -34,7 +34,6 @@ export const userGroup = new Elysia()
|
|
| 34 |
email: locals.user.email,
|
| 35 |
isAdmin: locals.user.isAdmin ?? false,
|
| 36 |
isEarlyAccess: locals.user.isEarlyAccess ?? false,
|
| 37 |
-
isPro: locals.user.isPro ?? false,
|
| 38 |
}
|
| 39 |
: null;
|
| 40 |
})
|
|
|
|
| 34 |
email: locals.user.email,
|
| 35 |
isAdmin: locals.user.isAdmin ?? false,
|
| 36 |
isEarlyAccess: locals.user.isEarlyAccess ?? false,
|
|
|
|
| 37 |
}
|
| 38 |
: null;
|
| 39 |
})
|
src/lib/types/User.ts
CHANGED
|
@@ -11,5 +11,4 @@ export interface User extends Timestamps {
|
|
| 11 |
hfUserId: string;
|
| 12 |
isAdmin?: boolean;
|
| 13 |
isEarlyAccess?: boolean;
|
| 14 |
-
isPro?: boolean;
|
| 15 |
}
|
|
|
|
| 11 |
hfUserId: string;
|
| 12 |
isAdmin?: boolean;
|
| 13 |
isEarlyAccess?: boolean;
|
|
|
|
| 14 |
}
|
src/routes/+layout.svelte
CHANGED
|
@@ -131,8 +131,7 @@
|
|
| 131 |
isPro.set(userData.isPro ?? false);
|
| 132 |
})
|
| 133 |
.catch(() => {
|
| 134 |
-
//
|
| 135 |
-
isPro.set(data.user?.isPro ?? false);
|
| 136 |
});
|
| 137 |
}
|
| 138 |
|
|
|
|
| 131 |
isPro.set(userData.isPro ?? false);
|
| 132 |
})
|
| 133 |
.catch(() => {
|
| 134 |
+
// Keep isPro as null on error - don't show any badge if status is unknown
|
|
|
|
| 135 |
});
|
| 136 |
}
|
| 137 |
|
src/routes/login/callback/updateUser.ts
CHANGED
|
@@ -39,7 +39,6 @@ export async function updateUser(params: {
|
|
| 39 |
picture: avatarUrl,
|
| 40 |
sub: hfUserId,
|
| 41 |
orgs,
|
| 42 |
-
isPro,
|
| 43 |
} = z
|
| 44 |
.object({
|
| 45 |
preferred_username: z.string().optional(),
|
|
@@ -47,7 +46,6 @@ export async function updateUser(params: {
|
|
| 47 |
picture: z.string().optional(),
|
| 48 |
sub: z.string(),
|
| 49 |
email: z.string().email().optional(),
|
| 50 |
-
isPro: z.boolean().optional(),
|
| 51 |
orgs: z
|
| 52 |
.array(
|
| 53 |
z.object({
|
|
@@ -74,7 +72,6 @@ export async function updateUser(params: {
|
|
| 74 |
picture?: string;
|
| 75 |
sub: string;
|
| 76 |
name: string;
|
| 77 |
-
isPro?: boolean;
|
| 78 |
orgs?: Array<{
|
| 79 |
sub: string;
|
| 80 |
name: string;
|
|
@@ -137,7 +134,7 @@ export async function updateUser(params: {
|
|
| 137 |
// update existing user if any
|
| 138 |
await collections.users.updateOne(
|
| 139 |
{ _id: existingUser._id },
|
| 140 |
-
{ $set: { username, name, avatarUrl, isAdmin, isEarlyAccess
|
| 141 |
);
|
| 142 |
|
| 143 |
// remove previous session if it exists and add new one
|
|
@@ -167,7 +164,6 @@ export async function updateUser(params: {
|
|
| 167 |
hfUserId,
|
| 168 |
isAdmin,
|
| 169 |
isEarlyAccess,
|
| 170 |
-
isPro,
|
| 171 |
});
|
| 172 |
|
| 173 |
userId = insertedId;
|
|
|
|
| 39 |
picture: avatarUrl,
|
| 40 |
sub: hfUserId,
|
| 41 |
orgs,
|
|
|
|
| 42 |
} = z
|
| 43 |
.object({
|
| 44 |
preferred_username: z.string().optional(),
|
|
|
|
| 46 |
picture: z.string().optional(),
|
| 47 |
sub: z.string(),
|
| 48 |
email: z.string().email().optional(),
|
|
|
|
| 49 |
orgs: z
|
| 50 |
.array(
|
| 51 |
z.object({
|
|
|
|
| 72 |
picture?: string;
|
| 73 |
sub: string;
|
| 74 |
name: string;
|
|
|
|
| 75 |
orgs?: Array<{
|
| 76 |
sub: string;
|
| 77 |
name: string;
|
|
|
|
| 134 |
// update existing user if any
|
| 135 |
await collections.users.updateOne(
|
| 136 |
{ _id: existingUser._id },
|
| 137 |
+
{ $set: { username, name, avatarUrl, isAdmin, isEarlyAccess } }
|
| 138 |
);
|
| 139 |
|
| 140 |
// remove previous session if it exists and add new one
|
|
|
|
| 164 |
hfUserId,
|
| 165 |
isAdmin,
|
| 166 |
isEarlyAccess,
|
|
|
|
| 167 |
});
|
| 168 |
|
| 169 |
userId = insertedId;
|