Skip to content

Commit a00dfb5

Browse files
committed
feat: finalize Better Auth migration with schema and cleanup
- Update Convex schema to work with Better Auth user structure - Remove deprecated feedback functionality and middleware - Update hooks and pages to use new auth patterns - Regenerate Convex API types for Better Auth integration - Update HTTP handlers and instrumentation for new auth system - Update README documentation for Better Auth setup This completes the migration from Convex Auth to Better Auth, removing deprecated code and ensuring consistency across the application.
1 parent 403f3b8 commit a00dfb5

File tree

14 files changed

+5304
-67
lines changed

14 files changed

+5304
-67
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ Configure the required and optional Convex environment variables for your applic
195195

196196
#### A. Authentication (Required)
197197

198-
OS Chat uses Convex Auth for authentication with Google OAuth.
198+
OS Chat uses Better Auth for authentication with Google OAuth.
199199

200-
1. **Initialize Convex Auth:**
200+
1. **Configure Better Auth:**
201201

202202
```bash
203-
# Initialize Convex Auth setup
204-
bunx @convex-dev/auth
203+
# Better Auth is already configured in the codebase
204+
# Set up your Google OAuth credentials in the Convex dashboard
205205
```
206206

207207
2. **Set up Google OAuth:**
@@ -274,7 +274,7 @@ bunx convex env set POLAR_WEBHOOK_SECRET your-polar-webhook-secret
274274

275275
**Reference Documentation:**
276276

277-
- [Convex Auth Setup Guide](https://labs.convex.dev/auth/setup)
277+
- [Convex Better Auth Documentation](https://convex-better-auth.netlify.app/)
278278
- [Google OAuth Configuration](https://labs.convex.dev/auth/config/oauth/google)
279279
- [Cloudflare R2 Component](https://www.convex.dev/components/cloudflare-r2)
280280
- [Polar Component Documentation](https://www.convex.dev/components/polar)
@@ -336,7 +336,7 @@ For production deployment:
336336

337337
- Verify OAuth credentials in Convex dashboard
338338
- Check `SITE_URL` matches your development/production URL
339-
- Ensure Convex Auth is properly configured
339+
- Ensure Better Auth is properly configured
340340

341341
**API Key Issues**:
342342

@@ -353,7 +353,7 @@ For production deployment:
353353
**Need Help?**
354354

355355
- Check the [Convex Documentation](https://docs.convex.dev)
356-
- Review the [Convex Auth Setup Guide](https://labs.convex.dev/auth/setup)
356+
- Review the [Convex Better Auth Documentation](https://convex-better-auth.netlify.app/)
357357
- See [Google OAuth Configuration](https://labs.convex.dev/auth/config/oauth/google) for authentication
358358
- Configure [Cloudflare R2](https://www.convex.dev/components/cloudflare-r2) for file storage
359359
- Get an [Exa API key](https://exa.ai/) for web search functionality

app/c/[chatId]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { convexAuthNextjsToken } from "@convex-dev/auth/nextjs/server";
21
import { fetchQuery } from "convex/nextjs";
32
import { redirect } from "next/navigation";
43
import { api } from "@/convex/_generated/api";
54
import type { Id } from "@/convex/_generated/dataModel";
5+
import { getToken } from "@/lib/auth-server";
66

77
import Chat from "../../components/chat/chat";
88

@@ -12,7 +12,7 @@ export default async function ChatPage({
1212
params: Promise<{ chatId: string }>;
1313
}) {
1414
// Validate the chat on the server to avoid client-side flashes.
15-
const token = await convexAuthNextjsToken();
15+
const token = await getToken();
1616

1717
// If we fail to obtain a token (anonymous visitor with cookies disabled, etc.)
1818
// we still attempt the query – Convex will treat it as anonymous and only

app/hooks/use-model-preferences.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function useModelPreferences() {
2424
}
2525

2626
const newFavorites = isFavorite
27-
? favorites.filter((id) => id !== modelId)
27+
? favorites.filter((id: string) => id !== modelId)
2828
: [...favorites, modelId];
2929

3030
localStore.setQuery(
@@ -50,7 +50,7 @@ export function useModelPreferences() {
5050

5151
// Remove favorite models from disabled list (auto-enable favorites)
5252
const newDisabled = currentDisabled.filter(
53-
(id) => !newFavorites.includes(id)
53+
(id: string) => !newFavorites.includes(id)
5454
);
5555

5656
localStore.setQuery(

app/hooks/use-model-settings.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function useModelSettings() {
2727

2828
if (enabled) {
2929
// Enabling model - remove from disabled list
30-
newDisabled = currentDisabled.filter((id) => id !== modelId);
30+
newDisabled = currentDisabled.filter((id: string) => id !== modelId);
3131
} else {
3232
// Disabling model - add to disabled list and remove from favorites
3333
if (modelId === MODEL_DEFAULT) {
@@ -37,13 +37,13 @@ export function useModelSettings() {
3737
newDisabled = currentDisabled.includes(modelId)
3838
? currentDisabled
3939
: [...currentDisabled, modelId];
40-
newFavorites = currentFavorites.filter((id) => id !== modelId);
40+
newFavorites = currentFavorites.filter((id: string) => id !== modelId);
4141

4242
// Ensure at least one favorite remains
4343
if (newFavorites.length === 0 && currentFavorites.length > 0) {
4444
const firstFavorite = currentFavorites[0];
4545
newFavorites = [firstFavorite];
46-
newDisabled = newDisabled.filter((id) => id !== firstFavorite);
46+
newDisabled = newDisabled.filter((id: string) => id !== firstFavorite);
4747
}
4848
}
4949

@@ -70,11 +70,13 @@ export function useModelSettings() {
7070
const currentDisabled = currentUser.disabledModels ?? [];
7171

7272
// Filter out MODEL_DEFAULT from the models to disable
73-
const modelsToDisable = modelIds.filter((id) => id !== MODEL_DEFAULT);
73+
const modelsToDisable = modelIds.filter(
74+
(id: string) => id !== MODEL_DEFAULT
75+
);
7476

7577
// Remove disabled models from favorites
7678
let newFavorites = currentFavorites.filter(
77-
(id) => !modelsToDisable.includes(id)
79+
(id: string) => !modelsToDisable.includes(id)
7880
);
7981
// Merge with existing disabled models
8082
let newDisabled = [...new Set([...currentDisabled, ...modelsToDisable])];
@@ -83,7 +85,7 @@ export function useModelSettings() {
8385
if (newFavorites.length === 0 && currentFavorites.length > 0) {
8486
const firstFavorite = currentFavorites[0];
8587
newFavorites = [firstFavorite];
86-
newDisabled = newDisabled.filter((id) => id !== firstFavorite);
88+
newDisabled = newDisabled.filter((id: string) => id !== firstFavorite);
8789
}
8890

8991
localStore.setQuery(

app/privacy/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default function PrivacyPage() {
127127
responses
128128
</li>
129129
<li>
130-
<strong>Authentication:</strong> Convex Auth for secure login
130+
<strong>Authentication:</strong> Better Auth for secure login
131131
</li>
132132
<li>
133133
<strong>Payments:</strong> Polar for subscription billing

app/security/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function SecurityPage() {
4848
<strong>Access Controls:</strong>
4949
</p>
5050
<ul>
51-
<li>Authentication via Google OAuth through Convex Auth</li>
51+
<li>Authentication via Google OAuth through Better Auth</li>
5252
<li>Users can only access their own data</li>
5353
<li>Server-side validation for all data access requests</li>
5454
<li>

0 commit comments

Comments
 (0)